Question
What is the primary difference between recursion and
iteration in programming?Solution
Recursion involves a function calling itself until a base condition is met. Each recursive call creates a new stack frame, leading to memory usage that grows with the depth of recursion. Iteration, on the other hand, uses loops and does not involve stack frame creation, making it more memory-efficient in many cases. Why Other Options Are Incorrect: 1. Recursion uses loops for repetition, whereas iteration does not: This statement reverses the roles. Recursion relies on function calls for repetition, while iteration explicitly uses loops (for, while). 2. Iteration cannot solve problems that recursion can solve: Iteration can replicate recursion's functionality by using stacks or queues explicitly. Recursion is often a stylistic or practical choice, not a limitation of iteration. 3. Recursion is always faster than iteration: Recursion can sometimes be slower due to stack overhead and repeated function calls. Tail-call optimization can mitigate this in some languages, but generally, iteration is faster for equivalent tasks. 4. Recursion does not require a base case, while iteration requires a condition: Recursion must have a base case to terminate; otherwise, it leads to infinite calls. Iteration, too, requires a stopping condition, such as a loop exit condition.
Which institution has created a framework for transfer of stressed loans from domestic lenders to financial institutions?
 _______ country is organizing the ‘Tsentr -2019’ exercise between the armies of India, China and Pakistan to test the combat-readiness of the mili...
Who among the following was appointed, to the UN tax committee in July 2021, as a member for the 2021 to 2025 term?Â
Dutch author Marieke Lucas has won the International Booker Prize 2020 for the book named:
Out of the seven agriculture schemes recently launched by the Government of India, which scheme received the highest and the second-highest budget alloc...
Which among the following countries is/are NOT a member of the QUAD (Quadrilateral Security Dialogue)?
Who was the Governor-General when the first railway line was laid?
IRDA was formed based on the recommendations of which committee?
First State of Global Water Resources report is published by __________ in order to assess the effects of climate, environmental and societal change on ...
Which empire/ dynasty was founded by the Harihara I and Bukka?