Question: Iterative Inorder: We gave a linear-time non-recursive Inorder procedure using parent pointers. (a) If parent pointers are not available, one could maintain a stack holding
Iterative Inorder: We gave a linear-time non-recursive Inorder procedure using parent pointers. (a) If parent pointers are not available, one could maintain a stack holding the ancestors of the current node. Write such a procedure and analyze its running time. (b) Write a linear-time non-recursive in-place Inorder procedure without parent pointers. (In-place means you cannot use any stack or equivalent; just the given tree and O(1) additional scalar variables.) [Hint: temporarily modify the tree links then put them back into their original form.]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
