Question 4Asked in Bihar STET 2025 Paper II Computer Science, 7 Nov 2025, Shift 1 (9:00 AM)

The Floyd-Warshall algorithm is a popular method for solving the All-Pair Shortestफ्लोयड-वार्शेल एल्गोरिथ्म ऑल-जोयर सबसे छोटी पथ समस्या को हल करने के लिए एक लोकप्रिय

The Floyd-Warshall algorithm is a popular method for solving the All-Pair Shortest Paths problem. What is the time complexity of the Floyd-Warshall algorithm for a graph with "n" vertices?
फ्लोयड-वार्शेल एल्गोरिथ्म ऑल-जोयर सबसे छोटी पथ समस्या को हल करने के लिए एक लोकप्रिय तरीका है। "एन" वर्टिस के साथ एक ग्राफ के लिए फ्लोयड-वॉशेल एल्गोरिथ्म की समय जटिलता क्या है?
  1. AO(n)ओ (एन)
  2. BO(n log n)ओ (एन लॉग एन)
  3. CO(n^2)ओ (एन^2)
  4. DO(n^3)ओ (एन^3)
Show answerHide answer

Correct answer: (D) O(n^3)ओ (एन^3)

Explanation

Floyd-Warshall uses three nested loops over the n vertices (intermediate k, source i, destination j), so it does n × n × n updates, giving O(n³) time.Floyd-Warshall n शीर्षों पर तीन नेस्टेड लूप (मध्यवर्ती k, स्रोत i, गंतव्य j) चलाता है, इसलिए n × n × n अद्यतन करता है, यानी O(n³) समय।

From Bihar STET 2025 Paper II Computer Science PYQ, 7 Nov 2025, Shift 1 (9:00 AM)

This is question 4 of Bihar STET 2025 Paper II Computer Science PYQ, 7 Nov 2025, Shift 1 (9:00 AM). See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.