1,426 views
1 1 vote
Every recursive program uses strictly more stack space compared to its iterative equivalent.

This statement is false. Please explain with examples

2 Answers

1 1 vote
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 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.
Position:
Show:

Related questions

0 0 votes
2 2 answers
519
519 views
2 2 votes
2 2 answers
2.4k
2.4k views
Gurdeep Saini asked Jan 2, 2019
2,369 views
true/false ?) if stack is implemented as a array,all operation push ,pop ,is emptystack(),delete stack() can be performed in constant time.)if stack is implemented as a l...
2 2 votes
0 0 answers
838
838 views
CHïntän ÞäTël asked Dec 7, 2018
838 views
I THING THERE IS MISTAKE BECAUSE BRACKET ARE CLOSING AFTER ELEMENT E SO ALL OPERATORS HOULD BE POPED AND AND ACCORDING TO ME ANWER SHOLD BE 2…TRY AND CORRECT IF I M WRON...
1 1 vote
1 1 answer
2.5k
2.5k views
radha gogia asked Jul 24, 2018
2,457 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...