1 1 vote Every recursive program uses strictly more stack space compared to its iterative equivalent. This statement is false. Please explain with examples Programming in C stack data-structures + – Shamim Ahmed 1.4k views answer comment Share Follow Print See all 2 Comments 2 2 Comments reply Shubhanshu commented Dec 11, 2018 reply Follow flag It is totally dependent on the Implementation. 0 0 replyShare Shamim Ahmed commented Dec 11, 2018 reply Follow flag can you explain it more accurately? 0 0 replyShare Please log in or register to add a comment.
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. neeraj33negi answered Dec 11, 2018 neeraj33negi comment Share Follow See all 3 Comments 3 3 Comments reply Shamim Ahmed commented Dec 11, 2018 reply Follow flag Can iterative version can ever take more stack space than recursive counterpart? 0 0 replyShare neeraj33negi commented Dec 11, 2018 reply Follow flag No, if implemented properly. 0 0 replyShare MiNiPanda commented Dec 16, 2018 reply Follow flag @neeraj33negi Kindly elaborate with an example.. 0 0 replyShare Please log in or register to add a comment.
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. DAWID15 answered Dec 23, 2021 DAWID15 comment Share Follow 0 reply Please log in or register to add a comment.