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?
फ्लोयड-वार्शेल एल्गोरिथ्म ऑल-जोयर सबसे छोटी पथ समस्या को हल करने के लिए एक लोकप्रिय
तरीका है। "एन" वर्टिस के साथ एक ग्राफ के लिए फ्लोयड-वॉशेल एल्गोरिथ्म की समय जटिलता क्या है?
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³) समय।