State any two differences between iteration and recursion.
Answer
Answer
AIWritten by AI (antigravity) - it can contain mistakes.
Two differences between iteration and recursion:
1. Execution mechanism: Iteration repeatedly executes a block of statements using looping constructs (for, while, do-while) until a condition is satisfied, whereas recursion repeatedly executes code by a method calling itself with a smaller problem until a base condition is reached.
2. Memory overhead: Iteration does not use additional call stack frames for each cycle (O(1) auxiliary stack space), whereas recursion allocates a new stack frame on the call stack for each call, consuming additional memory and carrying the risk of StackOverflowError if the recursion depth is too large.
From ISC 2026 Computer Science Paper 1, question 7(ii).