Which of the following data structures finds its use in recursion?
2023
Which of the following data structures finds its use in recursion?
- A.
Stack
- B.
Linked list
- C.
Array
- D.
More than one of the above
- E.
None of the above
Attempted by 1177 students.
Show answer & explanation
Correct answer: A
Recursion involves a function calling itself, and each call needs to be managed in memory. The system uses a call stack to store information about function calls, including return addresses and local variables. This stack follows the Last In, First Out (LIFO) principle, which is the defining behavior of a stack data structure. Therefore, stack is essential for managing recursive function calls.
Linked lists and arrays do not inherently support the LIFO behavior required for recursion. While they can be used in recursive algorithms, they are not the primary data structures for managing recursion. Option D suggests more than one data structure is used, but only stack is fundamental. Option E is incorrect because stack is used in recursion.
हिन्दी उत्तर: रिकर्शन में एक फंक्शन खुद को कॉल करता है, और प्रत्येक कॉल को मेमोरी में प्रबंधित करने की आवश्यकता होती है। सिस्टम एक कॉल स्टैक का उपयोग करता है जो फंक्शन कॉल के बारे में जानकारी, जैसे रिटर्न एड्रेस और स्थानीय चर, संग्रहीत करता है। यह स्टैक लास्ट इन, फर्स्ट आउट (LIFO) सिद्धांत का पालन करता है, जो स्टैक डेटा संरचना की परिभाषात्मक व्यवहार है। इसलिए, स्टैक रिकर्शन के लिए आवश्यक है।
लिंक्ड लिस्ट और एरे रिकर्शन के लिए आवश्यक LIFO व्यवहार का समर्थन नहीं करते हैं। हालांकि वे रिकर्शन एल्गोरिदम में उपयोग किए जा सकते हैं, लेकिन वे रिकर्शन के प्रबंधन के लिए प्राथमिक डेटा संरचना नहीं हैं। विकल्प D अधिक से अधिक डेटा संरचनाओं का उपयोग करता है, लेकिन केवल स्टैक आवश्यक है। विकल्प E गलत है क्योंकि स्टैक रिकर्शन में उपयोग किया जाता है।