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.
- Identify the misspelt word among the following given options:
Four words are given, out of which only one word is spelt correctly. Choose the correctly spelt word.
From the options given below, select the option which states the correct combination of incorrect sentences.
I. Recently, there has been a lot of...
Choose the word with correct spelling.
In each group, one word is correctly spelt. Find the correct word.
Election is scheduled (A) early this year, with the Election Commission of India team being told by political parties in the State that they were in fav...
In the following questions four words are given in bold. One of them maybe incorrectly spelt identify the incorrectly spelt word. If all are correct ch...
In the following sentence, four words or phrases have been highlighted. One of them is incorrect. Choose the INCORRECT word or phrase from the given opt...
- In each sentence below four words have been printed in bold which are numbered (1), (2), (3) and (4) One of these words may be misspelt or inappropriate in...
- Identify the INCORRECTLY spelt word in the following sentence and select its correct spelling from the given options.
She always accomodates her g...