• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

Quiz On Tree Data Structure

Question 1

For the expression (7-(4*5))+(9/3) which of the following is the post order tree traversal?

  • *745-93/+

  • 93/+745*-

  • 745*-93/+

  • 74*+593/-

Question 2

Which traversal's pseudo code is written here?

order(node)
Q → Queue()
Q.push(node)
while !Q.empty():
    current_node = Q.pop()
    print current_node.value
if current_node.left is not NULL:
    Q.push(current_node.left)
if current_node.right is not NULL:
    Q.push(current_node.right)
  • Level order

  • Pre-order

  • Post-order

  • In-order

Question 3

Which traversal is shown by this pseudo code?

Order(node):
  if node is not null:
   Order(node.left)
  print node.value
    Order(node.right)
  • In-order

  • Level Order

  • Post-order

  • Pre-order

Question 4

The time complexity of calculating the sum of all leaf nodes in an n-order binary tree is __________

  • O(n2)

  • O(n+1)

  • O(1)

  • O(n)
     

Question 5

What is a full binary tree?

  • Each node has exactly zero or two children

  • Each node has exactly two children

  • All the leaves are at the same level

  • Each node has exactly one or two children

Question 6

An important application of binary tree is ______

  • Huffman coding

  • stack implementation

  • queue implementation

  • traverse a cyclic graph

Question 7

In a full binary tree if there are L leaves, then total number of nodes N are?

  • N = 2*L

  • N = L + 1

  • N = L – 1

  • N = 2*L – 1

Question 8

Which among the following is the pseudo code for post-order traversal?

  • Order(node):
        if node is not null:
           Order(node.left)
           Order(node.right)
           print node.value
  • Order(node):
        if node is not null:
           Order(node.right)
           Order(node.left)
            print node.value
  • Order(node):
        if node is not null:
           Order(node.left)
            print node.value
  • None of the above

Question 9

Construct a binary tree by using post-order and in-order sequences given below.
In-order: N, M, P, O, Q
Post-order: N, P, Q, O, M

  • A binary tree by using postorder & inorder sequences - option a

  • A binary tree by using postorder & inorder sequences - option b

  • A binary tree by using postorder & inorder sequences - option c

  • A binary tree by using postorder & inorder sequences - option d

Question 10

Which of the following is not an advantage of trees?

  • Hierarchical structure

  • Faster search

  • Router algorithms

  • Undo/Redo operations in a notepad

There are 10 questions to complete.

Last Updated :
Take a part in the ongoing discussion