in Programming in C recategorized by
6,376 views
24 votes
24 votes

Consider the class of recursive and iterative programs. Which of the following is false?

  1. Recursive programs are more powerful than iterative programs.
  2. For every iterative program there is an equivalent recursive program.
  3. Recursive programs require dynamic memory management.
  4. Recursive programs do not terminate sometimes.
  5. Iterative programs and recursive programs are equally expressive.
in Programming in C recategorized by
6.4k views

2 Comments

@VIKAS TIWARI

i didn't get any information related to this question from the link you shared !

0
0

2 Answers

21 votes
21 votes

Answer is option E.

Computable function: those which can be incorporated in a program using for/while loops.

Total Function: Defined for all possible inputs

Well Defined: if its definition assigns it a unique value.

It was a belief in early $1900$s that every Computable function was also Primitively Recursive. But the discovery of Ackermann function provided a counter to it.

The class of primitive recursive functions is a small subclass of the class of recursive functions. This means that there are some functions which are Well-Defined Total Functions and are Computable BUT Not primitively recursive; eg. Ackermann function.

This makes all options from option A to option D as True.

But option E as $\text{FALSE}$. As iterative programs are equivalent to only Primitively Recursive class.

edited by

4 Comments

arjun sir nested recursion is also a non primitive recursion
0
0
I don't think this answer is correct.
0
0

@Arjun sir from the above discussion can we say that recursive program is more powerful than iterative programs. Can you provide an example?

 

1
1
15 votes
15 votes

Answer is option $A$

$\text{A. Recursive programs are more powerful than iterative programs}$. 

This is $\text{false }$as there exist an iterative program for every recursive program.

Primitive recursive functions correspond to programs using bounded iteration, that is, you have to specify the number of iterations that a loop is executed in advance. Bounded iteration cannot simulate recursion in general, since the Ackermann function isn't primitive recursive. But unbounded iteration can simulate any partially computable function.

$\text{B. For every iterative program there is an equivalent recursive program.}$ True

$\text{C. Recursive programs require dynamic memory management.}$

True, as number of calls is not known advance for recursive functions.

$\text{D. Recursive programs do not terminate sometimes.}$ True

$\text{E. Iterative programs and recursive programs are equally expressive.}$

True.  Here is an "iterative" algorithm for the Ackermann function

 

 

4 Comments

I think option A is true. Consider tower of hanoi problem we don't have iterative program yet and hence we always use recursive approach so I think option E is false
0
0
This answer is correct, in my humble opinion.

The Church-Turing thesis (yet to be proved, but also yet to be unproved) tells you that everything that's "computable" can be computed by a Turing Machine. Turing Machine is an iterative model.

Any recursive program can be converted into an iterative version and vice versa. They have equal expressive powers.

 

Also, in my humble opinion again, the "if they're allowed to use a stack" is not a valid counter-point. Stack isn't the characteristic of recursion — it is the other way around. Recursion needs stack. Always. Doesn't mean that if you use a stack you're performing some recursive action.

Every local variable uses stack. If you just declare "int i" inside a function, it's saved in the stack. So every program that uses any variable is recursive?

 

No example exists that shows a recursive program that can't be implemented via iteration.
5
5

@khardnaman

You're one Google search away from editing that comment.

0
0
Answer:

Related questions