Machine-translated by Google. Questions are authored in English.
Top

Discussion

In case of recursion which of the following statements is false ?

  • A.Every recursive program can have an alternative iterative program
  • B.Simplifies the logic
  • C.Generally recursive version of programs take less space over iterative counter part
  • D.Options (A) & (C) only

Answer: C

The false statement is Generally recursive version of programs take less space over iterative counter part.

Each recursive call pushes a new activation record, with its parameters, local variables and return address, onto the stack. A recursion of depth n therefore uses stack space proportional to n, while an equivalent loop reuses the same variables. Recursive versions generally take more space, not less.

The other statements are true: any recursive program can be rewritten iteratively, if necessary with an explicit stack, and recursion often simplifies the logic, as in tree traversal or the Tower of Hanoi. Option D wrongly includes the true statement A.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.