Quiz On Tree Data Structure

Last Updated :
Discuss
Comments

Question 1

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

  • A

    *745-93/+

  • B

    93/+745*-

  • C

    745*-93/+

  • D

    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)
  • A

    Level order

  • B

    Pre-order

  • C

    Post-order

  • D

    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)
  • A

    In-order

  • B

    Level Order

  • C

    Post-order

  • D

    Pre-order

Question 4

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

  • A

    O(n2)

  • B

    O(n+1)

  • C

    O(1)

  • D

    O(n)
     

Question 5

What is a full binary tree?

  • A

    Each node has exactly zero or two children

  • B

    Each node has exactly two children

  • C

    All the leaves are at the same level

  • D

    Each node has exactly one or two children

Question 6

An important application of binary tree is ______

  • A

    Huffman coding

  • B

    stack implementation

  • C

    queue implementation

  • D

    traverse a cyclic graph

Question 7

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

  • A

    N = 2*L

  • B

    N = L + 1

  • C

    N = L – 1

  • D

    N = 2*L – 1

Question 8

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

  • A
    Order(node):
        if node is not null:
           Order(node.left)
           Order(node.right)
           print node.value
  • B
    Order(node):
        if node is not null:
           Order(node.right)
           Order(node.left)
            print node.value
  • C
    Order(node):
        if node is not null:
           Order(node.left)
            print node.value
  • D

    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

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

  • B

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

  • C

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

  • D

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

Question 10

Which of the following is not an advantage of trees?

  • A

    Hierarchical structure

  • B

    Faster search

  • C

    Router algorithms

  • D

    Undo/Redo operations in a notepad

Tags:

There are 10 questions to complete.

Take a part in the ongoing discussion