What happens when a top-down approach of dynamic programming is applied to any…
2021
What happens when a top-down approach of dynamic programming is applied to any problem?
- A.
It increases both the time complexity and the space complexity
- B.
It increases the space complexity and decreases the time complexity
- C.
It increases the time complexity and decreases the space complexity
- D.
It decreases both the time complexity and the space complexity
- E.
Question not attempted
Attempted by 159 students.
Show answer & explanation
Correct answer: B
When a top-down approach of dynamic programming is applied to a problem, it uses recursion with memoization to store the results of subproblems. This avoids recomputing the same subproblems, which reduces the time complexity compared to naive recursion. However, storing the results in a memoization table requires additional memory, which increases the space complexity. Therefore, the top-down approach decreases time complexity but increases space complexity.
हिन्दी उत्तर: जब किसी समस्या पर ऊपर से नीचे की दिशा में डायनामिक प्रोग्रामिंग का उपयोग किया जाता है, तो यह मेमोइजेशन के साथ रिकर्शन का उपयोग करता है। इससे उप-समस्याओं के परिणामों को संग्रहीत किया जाता है, जिससे एक ही उप-समस्या की दोबारा गणना नहीं होती है। इससे समय जटिलता कम होती है, लेकिन मेमोइजेशन टेबल के लिए अतिरिक्त मेमोरी की आवश्यकता होती है, जिससे स्पेस जटिलता बढ़ जाती है। इसलिए, ऊपर से नीचे की दिशा में डायनामिक प्रोग्रामिंग समय जटिलता को कम करती है लेकिन स्पेस जटिलता को बढ़ाती है।