Tree Traversal MCQ Quiz - Objective Question with Answer for Tree Traversal - Download Free PDF

Last updated on Apr 22, 2025

Latest Tree Traversal MCQ Objective Questions

Tree Traversal Question 1:

Arrange the following steps of the Inorder Traversal of Binary Tree in the correct order.

A. Visit the Left subtree

B. Visit the Root node

C. Visit the Right subtree

D. Start traversing by visiting the nodes in rooted tree

E. Repeat the above three steps.

Choose the correct answer from the options given below:

  1. A, B, C, D, E
  2. E, A, B, C, D
  3. D, A, B, C, E
  4. D, A, E, B, C

Answer (Detailed Solution Below)

Option 3 : D, A, B, C, E

Tree Traversal Question 1 Detailed Solution

The correct answer is option 3: D, A, B, C, E

Key Points

Inorder traversal of a binary tree is a type of depth-first traversal where nodes are visited in the following order:

  • Step 1: Start traversing by visiting the nodes in the rooted tree.
  • Step 2: Visit the Left subtree.
  • Step 3: Visit the Root node.
  • Step 4: Visit the Right subtree.
  • Step 5: Repeat the above three steps for each subtree.

Tree Traversal Question 2:

qImage67a7385614ec8507bc4a04d8

Considering above binary tree, what will be the inorder traversal

  1. B A D C E G F H
  2. G H F E D C B A
  3. B A C D E G F H
  4. G H F D E B C A

Answer (Detailed Solution Below)

Option 1 : B A D C E G F H

Tree Traversal Question 2 Detailed Solution

The correct answer is 1) B A D C E G F H.

Key Points

  • Inorder traversal of a binary tree visits nodes in the following order: left subtree, root node, right subtree.
  • The provided sequence B A D C E G F H follows this rule, visiting the leftmost nodes first, then the root, and finally the rightmost nodes.

Additional Information

  • Inorder traversal is used to get nodes of a binary search tree (BST) in non-decreasing order.
  • This traversal method is used in many tree-related algorithms and problems.
  • It is also useful in scenarios where the order of node processing matters, such as expression trees for arithmetic operations.

Tree Traversal Question 3:

The post-order traversal of a binary tree is 8, 9, 6, 7, 4, 5, 2, 3, 1. The inorder traversal of the same tree is 8, 6, 9, 4, 7, 2, 5, 1, 3. The height of a tree is the length of the longest path from the root to any leaf. The height of the binary tree above is 

  1. 3
  2. 5
  3. 4
  4. 2

Answer (Detailed Solution Below)

Option 3 : 4

Tree Traversal Question 3 Detailed Solution

The correct answer is 4

Explanation:

To determine the height of the binary tree, we need to reconstruct the tree using the given post-order and in-order traversals and then calculate its height.

  • Post-order traversal (left, right, root): Given as 8, 9, 6, 7, 4, 5, 2, 3, 1. The last element (1) is the root of the tree.
  • In-order traversal (left, root, right): Given as 8, 6, 9, 4, 7, 2, 5, 1, 3. Locate the root (1), and split the in-order sequence into the left and right subtrees:
    • Left subtree (elements before 1): 8, 6, 9, 4, 7, 2, 5
    • Right subtree (elements after 1): 3
  • Repeat the process for each subtree:
    • Use post-order to identify the roots of the left and right subtrees.
    • Use in-order to split into further left and right subtrees recursively.

Reconstructing the Binary Tree:

quesImage479

Longest path has length 4.

Tree Traversal Question 4:

Given the following expression tree, identify the correct arithmetic expression:

F1 Raju.S 14-08-2020 Savita D 2

  1. (A + B)*/A-C
  2. (A - (B*C))/(A+C)
  3. A + B*C/A-C
  4. A + (B*C)/(A-C)
  5. (A + (B*C))/(A-C)

Answer (Detailed Solution Below)

Option 5 : (A + (B*C))/(A-C)

Tree Traversal Question 4 Detailed Solution

Concept:

Algorithm:

Step 1: Put operands into stack when we visiting operator last time go to step 2

Step 2: Calculate pop1 operator pop2 and again push into stack and Repeat Step 1

Step 3: Repeat Step 1 and Step 2 until Root node is visited last time

Explanation:

F1 Raju Shraddha 27.08.2020 D1

So option 5 is the correct answer.

Tree Traversal Question 5:

______ pairs of traversals is not sufficient to build a unique binary tree.

  1. None of the given options
  2. Preorder and Inorder
  3. Postorder and Inorder
  4. Postorder and Preorder

Answer (Detailed Solution Below)

Option 4 : Postorder and Preorder

Tree Traversal Question 5 Detailed Solution

The correct answer is Postorder and Preorder.

Key Points

  • Postorder and Preorder traversals are not sufficient to build a unique binary tree.
    • To uniquely construct a binary tree, you generally need the Inorder traversal paired with either Preorder or Postorder traversal.
    • Inorder traversal provides information about the relative positioning of nodes, which is crucial in tree reconstruction.
    • Without Inorder traversal, multiple binary trees can yield the same Postorder and Preorder traversals, making it impossible to determine a unique structure.

Additional Information

  • Inorder traversal is essential because it provides the relative positions of nodes in the tree, which cannot be derived from Preorder and Postorder traversals alone.
  • Preorder traversal lists nodes in the order of root, left subtree, and right subtree.
  • Postorder traversal lists nodes in the order of left subtree, right subtree, and root.
  • Example:
    • Consider a tree with nodes arranged such that multiple structures yield the same Preorder and Postorder traversals but differ in their Inorder traversal.
    • Without Inorder traversal, these different structures cannot be distinguished.

Top Tree Traversal MCQ Objective Questions

The pre-order traversal of a binary search tree is 15, 10, 12, 11, 20, 18, 16, 19.

Which one of the following is the post order traversal of the tree?

  1. 10, 11, 12, 15, 16, 18, 19, 20
  2. 11, 12, 10, 16, 19, 18, 20, 15
  3. 20, 19, 18, 16, 15, 12, 11, 10
  4. 19, 16, 18, 20, 11, 120, 10, 15

Answer (Detailed Solution Below)

Option 2 : 11, 12, 10, 16, 19, 18, 20, 15

Tree Traversal Question 6 Detailed Solution

Download Solution PDF

Concept:

A binary tree can be traversed in three ways:

  1. Preorder = (Root, Left subtree, Right Subtree)
  2. Inorder = (Left subtree, Root, Right Subtree)
  3. Postorder = (Left Subtree, Right subtree, Root)

 

Explanation:

In case of Binary Search Trees (BST), inorder traversal always sorts the tree nodes into ascending order.

Inorder traversal is 10, 11, 12, 15, 16, 18, 19, 20

Pre-order traversal is 15, 10, 12, 11, 20, 18, 16, 19.

In preorder traversal, the first node would be tree root and values less than root would be part of left

subtree and values greater than root node would form right subtree. So the resultant BST is:

Required Binary Search Tree:

F1 R.S Madhu 14.04.20 D1

Post order traversal: 11, 12, 10, 16, 19, 18, 20, 15

Consider a complete binary tree with 7 nodes. Let A denote the set of first 3 elements obtained by performing Breadth-First Search (BFS) starting from the root. Let B denote the set of first 3 elements obtained by performing Depth-First Search (DFS) starting from the root.

The value of |A - B| is _______

Answer (Detailed Solution Below) 1

Tree Traversal Question 7 Detailed Solution

Download Solution PDF

Answer: 1 to 1

Explanation

Consider the following Complete Binary Tree

F1 Shraddha Raju 17.03.2021 D11 

A - {A, B, C}

B - {A, B, D}

Set A contains the first 3 elements obtained while Performing BFS.

Set B contains the first 3 elements obtained while performing DFS.

B={A, B, D} ( with DFS multiple Sequences are possible you can select anyone Answer to this Question will be same for all those sequences).

| A - B | 

=|{ A, B, C } – { A, B, D }| 

=|{C}| = 1

What is the in-order successor of 15 in the given binary search tree?

F1 R.S Deepak 17.02.20 D4 1

  1. 18
  2. 6
  3. 17
  4. 20

Answer (Detailed Solution Below)

Option 3 : 17

Tree Traversal Question 8 Detailed Solution

Download Solution PDF

Concept –

The in-order sequence can be found following the chronology of Left-> Root-> Right.

Finding the in-order traversal sequence, we get 2, 3, 4, 6, 7, 9, 13, 15, 17, 18, 20.

The element that comes after 15 is its successor. It can be seen that 15’s successor is 17.

Explanation –

  • In-order successor of a node is the minimum element in right subtree of the node in consideration.
  • Here, in the right subtree of 15, 17 is the element with minimum value. Hence, 17 is 15’s in-order successor.
  • Similarly, for finding the in-order predecessor of a node, the element with maximum value in left sub-tree is the answer. Here, 13 is 15’s in-order predecessor.


portant Point:

Tricks works only when the tree is Binary Search Tree.

What is the sequence of nodes when applying in-order traversal on the binary tree given below?

F1 R.S Madhu 28.05.20 D2

  1. A, B, C, D, E, F, I, H, G
  2. A, C, D, E, B, F, G, H, I
  3. A, B, C, D, E, F, G, H, I
  4. I, H, G, F, E, D, C, B, A

Answer (Detailed Solution Below)

Option 3 : A, B, C, D, E, F, G, H, I

Tree Traversal Question 9 Detailed Solution

Download Solution PDF

Concept:

  • In-order Traversal:  Left -> Root -> Right
  • Pre-order Traversal:  Root -> Left -> Right
  • Post-order Traversal :  Left -> Right -> Root


Binary tree:

GATE CS MIX 6 7Q Raju D1

Inorder Traversal: A, B, C, D, E, F, G, H, I 

The postorder traversal of a binary tree is 8,9,6,7,4,5,2,3,1. The inorder traversal of the same tree is 8,6,9,4,7,2,5,1,3. The height of a tree is the length of the longest path from the root to any leaf. The height of the binary tree above is ______.

Answer (Detailed Solution Below) 4

Tree Traversal Question 10 Detailed Solution

Download Solution PDF

When we perform in order traversal on a binary tree, we get the ascending order array. The tree is:

  1. Heap tree
  2. Almost complete binary tree
  3. Binary search tree
  4. Cannot be determined

Answer (Detailed Solution Below)

Option 3 : Binary search tree

Tree Traversal Question 11 Detailed Solution

Download Solution PDF

Opttion 3: correct:

When we perform in order traversal on a binary tree, we get the ascending order array. The tree is binary search tree

Random binary search tree

5faad4d3b638c5df89d4ecdb 26 Nov 2020 Shashi D1

Post-order traversal is 23, 18, 27, 25, 10, 60, 80, 70, 30.

In-order traversal traversal is 10, 18, 23, 25, 27, 30, 60, 70, 80

Preorder traversal is 30, 10, 25, 18, 23, 27, 70, 60 ,80 

In order traversal, of the binary search tree is in ascending order.

If BDAECF and ABDCEF are inorder and preorder traversals of a binary tree (T) respectively, then post-order traversal of T is:

  1. DBFECA
  2. BDEFCA
  3. DBEFCA
  4. BDFEAC

Answer (Detailed Solution Below)

Option 3 : DBEFCA

Tree Traversal Question 12 Detailed Solution

Download Solution PDF

Data

In order is BDAECF

Preorder is ABDCEF

Binary tree

F1 Raju Shraddha 19.11.2020 D2

Therefore Post order will be DBEFCA

Consider the following statements.

S1 : The sequence of procedure calls corresponds to a preorder traversal of the activation tree.

S2 : The sequence of procedure returns corresponds to a postorder traversal of the activation tree.

Which one of the following options is correct?

  1. S1 is true and S2 is true
  2. S1 is false and S2 is true
  3. S1 is false and S2 is false
  4. S1 is true and S2 is false

Answer (Detailed Solution Below)

Option 1 : S1 is true and S2 is true

Tree Traversal Question 13 Detailed Solution

Download Solution PDF

Answer: Option 1

Explanation:

Statement 1:The sequence of procedure calls corresponds to a preorder traversal of the activation tree.

Consider following example 

Fun( int n )

{

 if( n==0 || n==1) 

  return n;

else {

return Fun(n/2) + Fun(n/2) ;

}

Suppose function call made as Fun(8). now recursion tree will be  

F1 Raju.S 01-04-21 Savita D18

The Function call sequence will be (in terms of n): 8, 4, 2, 1, 1, 2, 1, 1, 4, 2, 1, 1, 2, 1, 1 ( Same as pre-order traversal of the tree )

The Function Returning Sequence will be : 1, 1, 2, 1, 1, 2, 4, 1, 1, 2, 1, 1, 2, 4, 8 ( Same as post-order traversal of the tree)

Hence This Statement is correct.

Statement 2:

This Statement is also correct.

Consider the following Inorder and Preorder traversal of a tree

Inorder – D B E F A G H C

Preorder - A B D E F C G H

What is the Postorder Traversal of the same tree

  1. D F E B H C G A
  2. D F E B G H C A
  3. D F E B H G C A
  4. D F E H B G C A

Answer (Detailed Solution Below)

Option 3 : D F E B H G C A

Tree Traversal Question 14 Detailed Solution

Download Solution PDF

Concept:

  • Inorder and Preorder = Unique Binary tree
  • Inorder and Postorder = Unique Binary tree
  • Preorder and Postorder = More than one Binary tree
  • Inorder Traversal:  Left -> Root -> Right
  • Preorder Traversal:  Root -> Left -> Right
  • Post Order Traversal :  Left -> Right -> Root


Algorithm: (For Inorder and Preorder to make Binary tree)

Step 1: Pick a node in the same sequence in the Preorder

Step 2:  Make left and right of picked node from Inorder

Step 3: Repeat Step 1

Step 4: Repeat Step 2, Loop till the last element in pre order

Explanation:

Binary tree after using this algorithm on pre order and in order: 

F2 R.S 20.5.20 Pallavi D5

Final Binary tree

F2 R.S 20.5.20 Pallavi D6

Using Concept left-> right -> root for post order

Post order = D F E B H G C A

Hence option 3 is the correct answer.

 For the following binary tree, inorder traversal yields the expression: 

F1 Raju Shraddha 01.10.2020 D2 1

  1. a + bd* - ef / 
  2.  a + b*d - e/f
  3. abdef* / + - 
  4. - + * / abdef 

Answer (Detailed Solution Below)

Option 2 :  a + b*d - e/f

Tree Traversal Question 15 Detailed Solution

Download Solution PDF

Concept:

In the in-order traversal method, the left subtree is visited first, then the root and then the right subtree. Every node is a subtree in itself.

Explanation:

Given a binary tree : 

F1 Raju Shraddha 01.10.2020 D2 1

For this, we first visit the left - subtree of root -.

1) It will first print a. Then root, +  (a + )

2) Then it will go to right subtree, in this again left subtree of root *. It prints b , then * , then d  (a + b * d)

3) Then it print "-".  (a + b * d -)

4) Then move to right subtree. First print e, then /, then f .(e/f)

5) Final output will be :  a + b * d -  e/f

Get Free Access Now
Hot Links: teen patti yas teen patti master purana teen patti gold real cash teen patti master apk download teen patti tiger