Start learning 50% faster. Sign in now
Stacks are crucial in recursive algorithms because they support backtracking by maintaining a history of function calls. Every recursive call is pushed onto the stack, and when a base condition is met, the stack unwinds (pops) the calls in reverse order. This property is integral for problems like solving mazes, tree traversal (DFS), or evaluating expressions. The Last-In-First-Out (LIFO) nature of stacks ensures that the most recent state is resumed first, making them perfect for backtracking scenarios. Why Other Options Are Incorrect · Option 1 (Efficient sorting): Stacks are not inherently used for sorting. Algorithms like Quick Sort and Merge Sort do not directly depend on stacks for sorting efficiency. · Option 2 (Memory allocation for variables): This is managed by the program's runtime stack, not the data structure itself. · Option 4 (Managing concurrent processes): This is more relevant to queues or process schedulers. · Option 5 (Sorting data): Stacks are used in algorithms like stack-based parsing but are not designed for general sorting.
Which city won the "City with the Most Sustainable Transport System" award at the 17th Urban Mobility India Conference & Exhibition 2024?
Which country becomes the first to adopt UPI outside India?
Which ministry is responsible for the Jal Jeevan Mission?
Uranus is classified as which type of planet?
Which application was launched at the ICAR-Central Institute of Freshwater Aquaculture to support the ornamental fisheries sector in September 2024?
In February, 2024, Indian Prime Minister Narendra Modi inaugurated the BAPS Hindu Mandir in which city, marking the first Hindu temple in the Middle East?
Kathia wheat, recently got a GI tag, belongs to which state?