Which data structure is used for implementing recursion?

  • A. a) Stack
  • B. b) Queue
  • C. c) List
  • D. d) Array
Correct Answer: A. a) Stack
Stack is the data structure used for implementing recursion.

Explanation:

Recursion involves a function calling itself directly or indirectly.

Each time a function is called, a new activation record is created. This record contains information about the function's parameters, local variables, and return address.

To keep track of these activation records and ensure proper execution, a LIFO (Last In, First Out) data structure is needed.

Stack is the perfect LIFO data structure for this purpose.

When a function is called, its activation record is pushed onto the stack.

When the function returns, its activation record is popped off the stack.

This process allows the system to manage multiple function calls efficiently and correctly.

If you think there is any confusion in the given MCQs, you can comment below.

Follow us on WhatsApp

docmcqs.com is Pakistan's No.1 online platform for preparing for all types of exams including PPSC, FPSC, KPSC, SPSC, Ministry of Defence, and for one-paper MCQs. This includes Pedagogy MCQs, general knowledge MCQs, current affairs MCQs, and much more.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top