Question
What is the primary advantage of using a stack in
recursive algorithms?Solution
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 of the following statements is correct?
A company shall not capitalize its profits or reserves for the purpose of issuing fully paid-up bonus shares unless__________________
Which of the following is not a correct statement about expert opinion?
Any member shall be entitled to be furnished, within _____________ after he has made a request in that behalf to the company, and on payment of such fee...
The Governor of a State is appointed by the:
Which of the following is a necessary or are necessary ingredients to constitute accident as a defence under the IPC?
According to Section 36(4) of the Code on Wages, 2019, what is the purpose of carrying forward excess allocable surplus or minimum bonus to the succeedi...
A person can act as proxy on behalf of members not exceeding fifty and holding in the aggregate ___________________ of the company carrying voting rights
What is a "Promissory note" as defined
As per Art. 24 of the Indian Constitution, no child of ________ years of age shall be working in any hazardous employment in a factory?