• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

Top MCQs on Tree Traversal with Interview Question and Answers | DSA Quiz

Question 21

Consider the following sequence of nodes for the undirected graph given below.
a b e f d g c
a b e f c g d
a d g e b c f
a d b c g e f
A Depth First Search (DFS) is started at node a. The nodes are listed in the order they are first visited. Which all of the above is (are) possible output(s)?
2008_46
  • 1 and 3 only
  • 2 and 3 only
  • 2, 3 and 4 only
  • 1, 2, and 3

Question 22

Which of the following statement is false?
  • A tree with n nodes has (n-1) edges.
  • A labeled rooted binary tree can be uniquely constructed given its postorder and preorder traversal results.
  • A complete binary tree with n internal nodes has (n+1) leaves.
  • The maximum number of nodes in a binary tree of height h is (2^(h+1) -1).

Question 23

A complete n-ary tree is one in which every node has 0 or n sons. If x is the number of internal nodes of a complete n-ary tree, the number of leaves in it is given by
  • x(n-1)+1
  • xn-1
  • xn+1
  • x(n+1)

Question 24

Which of the following sequences denotes the post order traversal sequence of the given tree?
         a
       /   \\
      b     e
     / \\   /
    c  d  f
   /
  g

  • f e g c d b a
  • g c b d a f e
  • g c d b f e a
  • f e d g c b a

Question 25

Which of following option is not correct regarding depth first searching?
  • In a depth-first traversal of a graph G with V vertices, E edges are marked as tree edges. The number of connected components in G is (E - V).
  • Depth-first search requires O(V^2) time if implemented with an adjacency matrix.
  • Depth-first search requires O(V + E) time if implemented with adjacency lists
  • None of these

Question 26

The post-order traversal of a binary search tree is given by 2, 7, 6, 10, 9, 8, 15, 17, 20, 19, 16, 12. Then the pre-order traversal of this tree is:
  • 2, 6, 7, 8, 9, 10, 12, 15, 16, 17, 19, 20
  • 7, 6, 2, 10, 9, 8, 15, 16, 17, 20, 19, 12
  • 7, 2, 6, 8, 9, 10, 20, 17, 19, 15, 16, 12
  • 12, 8, 6, 2, 7, 9, 10, 16, 15, 19, 17, 20

Question 27

Let G be a simple undirected graph. Let TD be a depth first search tree of G. Let TB be a breadth first search tree of G. Consider the following statements. (I) No edge of G is a cross edge with respect to TD. (A cross edge in G is between two nodes neither of which is an ancestor of the other in TD). (II) For every edge (u, v) of G, if u is at depth i and v is at depth j in TB, then ∣i − j∣ = 1. Which of the statements above must necessarily be true?

  • I only

  • II only

  • Both I and II

  • Neither I nor II

Question 28

Suppose the numbers 7, 5, 1, 8, 3, 6, 0, 9, 4, 2 are inserted in that order into an initially empty binary search tree. The binary search tree uses the reversal ordering on natural numbers i.e. 9 is assumed to be smallest and 0 is assumed to be largest. The in-order traversal of the resultant binary search tree is
  • 9, 8, 6, 4, 2, 3, 0, 1, 5, 7
  • 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
  • 0, 2, 4, 3, 1, 6, 5, 9, 8, 7
  • 9, 8, 7, 6, 5, 4, 3, 2, 1, 0

Question 29

The in-order and pre-order traversal of a binary tree are d b e a f c g and a b d e c f g respectively. The post order traversal of a binary tree is
  • e d b g f c a
  • e d b f g c a
  • d e b f g c a
  • d e f g b c a

Question 30

Consider the following tree If the post order traversal gives ab-cd*+ then the label of the nodes 1,2,3,… will be
  • +,-,*,a,b,c,d
  • a,-,b,+,c,*,d
  • a,b,c,d,-,*,+
  • -,a,b,+,*,c,d

There are 42 questions to complete.

Last Updated :
Take a part in the ongoing discussion