692 views
1 votes
1 votes
Every recursive program uses strictly more stack space compared to its iterative equivalent.

This statement is false. Please explain with examples

2 Answers

1 votes
1 votes
My approach: Take inorder traversal of a binary tree. You'll need a custom stack if you want to implement the function with iterative version. On comparing this iterative version with recursive version of the inorder traversal, we find that both methods are using same number of stack frames. Recursive version is just easy and more intuitive.
0 votes
0 votes
How can iterative algorithm uses more space than it's equivalent recursive algorithm??? Even though both needs variable and program memory but recursive algorithm requires additional memory for stack.

Related questions

2 votes
2 votes
2 answers
1
2 votes
2 votes
0 answers
2
1 votes
1 votes
1 answer
3
radha gogia asked Jul 24, 2018
1,312 views
Suppose one character at a time comes as an input from a string of letters . There is an option either to 1) print the incoming letter or to 2) put the incoming letter on...
1 votes
1 votes
2 answers
4
srestha asked Jun 22, 2018
450 views
What is difference between $pop\left ( \right )$,$empty Stack\left ( \right )$,$delete Stack\left ( \right )$?Can all be performed in $O\left ( 1 \right )$ time?