AMP

Chapter 8: Iteration and Recursion — Online MCQ Test

COMPUTER SCIENCE · CLASS 11th · Tamil Nadu State Board
Practice Chapter 8: Iteration and Recursion with a free chapter-wise online MCQ test. This chapter covers: Focusing on repetitive execution techniques this chapter details loop invariants iteration strategies and recursive function definitions. Students design efficient algorithms using.... AI-generated questions from basic to board-exam level, with instant results and explanations.

Start Exam on Full Site →

Chapter 8: Iteration and Recursion — Important Questions & Answers

Which construct allows a set of instructions to be executed repeatedly based on a condition?
  • A. Selection
  • B. Iteration
  • C. Abstraction
  • D. Modularization
Answer: B. Iteration
Iteration is the process of executing a block of statements repeatedly as long as a specified condition is true.
A recursive function must always have a __________ to stop the process.
  • A. Loop counter
  • B. Base case
  • C. Global variable
  • D. Return type
Answer: B. Base case
A base case is mandatory in recursion to prevent infinite calls and provide a terminating condition.
What is a 'loop invariant' in the context of an iterative algorithm?
  • A. A variable that changes in every iteration
  • B. A condition that is always true before and after each iteration
  • C. The exit condition of the loop
  • D. The total number of iterations
Answer: B. A condition that is always true before and after each iteration
A loop invariant is a logical assertion that remains true throughout the execution of the loop.
Consider a recursive function: f(n) = f(n-1) + 2. If f(0)=1, what is the value of f(3)?
  • A. 5
  • B. 7
  • C. 9
  • D. 3
Answer: B. 7
f(0)=1, f(1)=3, f(2)=5, f(3)=7. The sequence adds 2 at each recursive step.
What happens if a recursive function lacks a well-defined base case?
  • A. It will always execute once and stop.
  • B. It results in a stack overflow error.
  • C. It will convert itself into an iterative loop.
  • D. It returns a null value automatically.
Answer: B. It results in a stack overflow error.
Without a base case, the function will call itself infinitely until the memory allocated for the call stack is exhausted.