Data Structure Questions and AnswersInorder Traversal
Congratulations  you have completed Data Structure Questions and AnswersInorder Traversal.
You scored %%SCORE%% out of %%TOTAL%%.
Your performance has been rated as %%RATING%%
Your answers are highlighted below.
Question 1 [CLICK ON ANY COICE TO KNOW RIGHT ANSWER] 
For the tree below, write the inorder traversal.
2, 7, 2, 6, 5, 11, 5, 9, 4  
2, 7, 5, 2, 6, 9, 5, 11, 4  
2, 5, 11, 6, 7, 4, 9, 5, 2  
2, 7, 5, 6, 11, 2, 5, 4, 9 
Question 1 Explanation:
Inorder traversal follows LNR(LeftNodeRight).
Question 2 [CLICK ON ANY COICE TO KNOW RIGHT ANSWER] 
For the tree below, write the levelorder traversal.
2, 7, 2, 6, 5, 11, 5, 9, 4  
2, 7, 5, 2, 6, 9, 5, 11, 4  
2, 5, 11, 6, 7, 4, 9, 5, 2  
2, 7, 5, 6, 11, 2, 5, 4, 9 
Question 2 Explanation:
Level order traversal follows a breadth first search approach.
Question 3 [CLICK ON ANY COICE TO KNOW RIGHT ANSWER] 
Select the code snippet which performs inorder traversal.
public void inorder(Tree root) { System.out.println(root.data); inorder(root.left); inorder(root.right); }  
public void inorder(Tree root) { inorder(root.left); System.out.println(root.data); inorder(root.right); }  
public void inorder(Tree root) { System.out.println(root.data); inorder(root.right); inorder(root.left); }  
None of the mentioned

Question 3 Explanation:
Inorder traversal follows LNR(LeftNodeRight).
Question 4 [CLICK ON ANY COICE TO KNOW RIGHT ANSWER] 
Select the code snippet which performs levelorder traversal.
public static void levelOrder(Tree root) { Queue<Node> queue=new LinkedList<Node>(); queue.add(root); while(!queue.isEmpty(  
public static void levelOrder(Tree root) { Queue<Node> queue=new LinkedList<Node>(); queue.add(root); while(!  
public static void levelOrder(Tree root) { Queue<Node> queue=new LinkedList<Node>(); queue.add(root); while(!queue.isEmpty(  
None of the mentioned 
Question 4 Explanation:
Firstly add the root node to the queue. Then for all the remaining nodes, pop the front end of the queue and print it, add the left and right children of the popped node to the queue.
Question 5 [CLICK ON ANY COICE TO KNOW RIGHT ANSWER] 
What is the space complexity of the inorder traversal in the recursive fashion? (d is the tree depth and n is the number of nodes)
O(1)  
O(nlogd)  
O(logd)  
O(d) 
Question 5 Explanation:
In the worst case we have d stack frames in the recursive call, hence the complexity is O(d).
Once you are finished, click the button below. Any items you have not completed will be marked incorrect.
There are 5 questions to complete.