Which data structure is used for implementing recursion

Options

  • A. Array
  • B. List
  • C. Queue
  • D. Stack

Correct Answer (Detailed Explanation is Below)

D. Stack

Detailed Explanation

Recursion works using the call stack.

  • When a function calls itself, the system:

    • Pushes the function’s local variables and state onto a stack.

    • After the function finishes, it pops the data from the stack.

  • This follows LIFO (Last In, First Out) principle.


❌ Other Options:

  • (a) Queue → Works on FIFO (First In, First Out).

  • (b) List → General collection, not specifically used for recursion.

  • (c) Array → Just a data storage structure.

OOps! You are currently offline.