The Floyd–Warshall algorithm for all-pair shortest paths computation is based…
2021
The Floyd–Warshall algorithm for all-pair shortest paths computation is based on:
- A.
Greedy paradigm
- B.
Divide-and-Conquer paradigm
- C.
Dynamic Programming paradigm
- D.
Heuristics
- E.
Question not attempted
Attempted by 250 students.
Show answer & explanation
Correct answer: C
The Floyd–Warshall algorithm computes the shortest paths between all pairs of vertices in a weighted graph. It works by iteratively improving the shortest path estimates between vertices by considering each vertex as an intermediate point. The algorithm uses a dynamic programming approach, where the solution is built by solving smaller subproblems and reusing their results. It maintains a distance matrix that is updated in a triple loop, where each iteration considers one vertex as a potential intermediate node. This method ensures that all possible paths are considered, and the optimal substructure property is exploited to build the final solution.
हिन्दी उत्तर: फ्लॉयड-वार्शॉल एल्गोरिथ्म एक भारित ग्राफ में सभी जोड़ी शीर्षों के बीच शॉर्टेस्ट पथ की गणना करता है। यह प्रत्येक शीर्ष को एक मध्यवर्ती बिंदु के रूप में विचार करके शॉर्टेस्ट पथ अनुमानों को बेहतर बनाने के लिए लगातार काम करता है। यह एल्गोरिथ्म डायनामिक प्रोग्रामिंग दृष्टिकोण का उपयोग करता है, जहां समाधान छोटी उपसमस्याओं को हल करके और उनके परिणामों का पुन: उपयोग करके बनाया जाता है। यह एक दूरी मैट्रिक्स बनाए रखता है जिसे तीन लूप के माध्यम से अपडेट किया जाता है, जहां प्रत्येक इटरेशन एक शीर्ष को एक संभावित मध्यवर्ती नोड के रूप में विचार करती है। इस विधि सुनिश्चित करती है कि सभी संभावित पथों को विचार किया जाता है, और अंतिम समाधान के लिए न्यूनतम उप-संरचना गुण का उपयोग किया जाता है।