# Data Structure Questions and Answers-Preorder Traversal

## Click on any option to know the CORRECT ANSWERS

 Question 1
For the tree below, write the pre-order traversal.
 A 2, 7, 2, 6, 5, 11, 5, 9, 4 B 2, 7, 5, 2, 6, 9, 5, 11, 4 C 2, 5, 11, 6, 7, 4, 9, 5, 2 D 2, 7, 5, 6, 11, 2, 5, 4, 9

Question 1 Explanation:
Pre order traversal follows NLR(Node-Left-Right).

 Question 2
For the tree below, write the post-order traversal.
 A 2, 7, 2, 6, 5, 11, 5, 9, 4 B 2, 7, 5, 2, 6, 9, 5, 11, 4 C 2, 5, 11, 6, 7, 4, 9, 5, 2 D 2, 7, 5, 6, 11, 2, 5, 4, 9

Question 2 Explanation:
Post order traversal follows LRN(Left-Right-Node).

 Question 3
Select the code snippet which performs pre-order traversal.
 A public void preorder(Tree root) { System.out.println(root.data); preorder(root.left); preorder(root.right); } B public void preorder(Tree root) { preorder(root.left); System.out.println(root.data); preorder(root.right); } C public void preorder(Tree root) { System.out.println(root.data); preorder(root.right); preorder(root.left); } D None of the mentioned

Question 3 Explanation:
Pre-order traversal follows NLR(Node-Left-Right).

 Question 4
Select the code snippet which performs post-order traversal.
 A public void postorder(Tree root) { System.out.println(root.data); postorder(root.left); postorder(root.right); } B public void postorder(Tree root) { postorder(root.left); postorder(root.right); System.out.println(root.data); } C public void postorder(Tree root) { System.out.println(root.data); postorder(root.right); postorder(root.left); } D None of the mentioned

Question 4 Explanation:
Post order traversal follows NLR(Left-Right-Node).

 Question 5
Select the code snippet that performs pre-order traversal iteratively.
 A public void preOrder(Tree root) { if (root == null) return; Stack stk = new Stack(); st.add< B public void preOrder(Tree root) { if (root == null) return; Stack stk = new Stack(); while (!stk. C public void preOrder(Tree root) { if (root == null) return; Stack stk = new Stack(); st.add(root) D None of the mentioned