---
title: "Which data structure is used to perform recursion?"  
description: "Which data structure is used to perform recursion?"  
author: "Mukul Goenka"  
published: 2021-11-15  
updated: 2023-05-01  
canonical: https://www.mindstick.com/interview/33824/which-data-structure-is-used-to-perform-recursion  
category: "data structure"  
tags: ["c#", "java", "data structure"]  
reading_time: 2 minutes  

---

# Which data structure is used to perform recursion?

Stack data structure is used in recursion due to its last in first out nature. Operating system maintains the stack in order to save the iteration variables at each function call.

## Answers

### Answer by Aryan Kumar

In computer programming, recursion is a technique where a function calls itself one or more times to solve a problem. To perform recursion, a data structure called the "call stack" is used.

When a function is called, the computer allocates a block of memory on the call stack to store the function's local variables and parameters. When the function is finished executing, this memory is freed and the program returns to the calling function.

Recursion works by pushing the current function call onto the call stack, and then calling the function again with different parameters. This creates a new block of memory on the call stack for the new function call. The function continues to call itself recursively until it reaches a base case, where the recursion terminates.

So, while recursion itself doesn't rely on any specific data structure, the call stack is the data structure that is used to manage the recursion.

### Answer by Mukul Goenka

Stack data structure is used in recursion due to its last in first out nature. Operating system maintains the stack in order to save the iteration variables at each function call.


---

Original Source: https://www.mindstick.com/interview/33824/which-data-structure-is-used-to-perform-recursion

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
