Question: Question:- Consider the given code and perform the following operations: a) Find out the missing statement for tree preorder traversal. b) Convert the code to
Question:-

Consider the given code and perform the following operations: a) Find out the missing statement for tree preorder traversal. b) Convert the code to perform tree traversal iteratively. public void preOrder(Tree root) if (root ==null) return; st.add(root); while (!stk.empty) Tree node = stk.pop(); System.out.print(node.data + " "); if (node.left != null) stk.push(node.left); } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
