Top MCQs on Binary Trees Data Structure with Answers

Binary Tree is defined as a tree data structure where each node has at most 2 children. Since each element in a binary tree can have only 2 children, we typically name them the left and right child. More on Binary Tree
Binary Tree Quiz

Binary Tree Quiz

Question 1

Which of the following is true about Binary Trees?

Cross

Every binary tree is either complete or full.

Cross

Every complete binary tree is also a full binary tree.

Cross

Every full binary tree is also a complete binary tree.

Cross

No binary tree is both complete and full.

Tick

None of the above



Question 1-Explanation: 

A full binary tree (sometimes proper binary tree or 2-tree or strictly binary tree) is a tree in which every node other than the leaves has two children. A complete binary tree is a binary tree in which every level, except possibly the last, is completely filled, and all nodes are as far left as possible. A) is incorrect. For example, the following Binary tree is neither complete nor full

     12
   /  
  20
 /
30

B) is incorrect. The following binary tree is complete but not full

     12
   /   \
  20    30
 /
30

C) is incorrect. Following Binary tree is full, but not complete

     12
   /   \
  20    30
       /  \  
      20   40

D) is incorrect. Following Binary tree is both complete and full

      12
    /   \
   20    30
  /  \  
 10   40
Question 2

If arity of operators is fixed, then which of the following notations can be used to parse expressions without parentheses? a) Infix Notation (Inorder traversal of a expression tree) b) Postfix Notation (Postorder traversal of a expression tree) c) Prefix Notation (Preorder traversal of a expression tree)

Tick

b and c

Cross

Only b

Cross

a, b and c

Cross

None of them



Question 2-Explanation: 

Preorder and Postorder notations are used to parse expressions without parentheses.

Question 3

What are the main applications of tree data structure?

  1. Manipulate hierarchical data 
  2. Make information easy to search  
  3. Manipulate sorted lists of data 
  4. Router algorithms 
  5. Form of a multi-stage decision-making, like Chess Game. 
  6. As a workflow for compositing digital images for visual effects
Cross

1, 2, 3, 4 and 6

Cross

1, 2, 3, 4 and 5

Cross

1, 3, 4, 5 and 6

Tick

1, 2, 3, 4, 5 and 6



Question 3-Explanation: 

Tree data structure is used to study or tabulate hierarchical data. Searching of data becomes easy using the tree traversals. Using BST we can easily analyze sorted data. Decision making to reach an objective becomes easy due to decision tree creation. Trees are used in router algorithms. They can be beneficial as a workflow for compositing digital images for visual effects.

Question 4
Level of a node is distance from root to that node. For example, level of root is 1 and levels of left and right children of root is 2. The maximum number of nodes on level i of a binary tree is

In the following answers, the operator '^' indicates power.
Tick
2^(i-1)
Cross
2^i
Cross
2^(i+1)
Cross
2^[(i+1)/2]


Question 4-Explanation: 
Number of nodes of binary tree will be maximum only when tree is full complete, therefore answer is 2^(i)-1 So, option (A) is true.
Question 5
In a complete k-ary tree, every internal node has exactly k children or no child. The number of leaves in such a tree with n internal nodes is:
Cross
nk
Cross
(n – 1) k+ 1
Tick
n( k – 1) + 1
Cross
n(k – 1)


Question 5-Explanation: 
For an k-ary tree where each node has k children or no children, following relation holds L = (k-1)*n + 1 Where L is the number of leaf nodes and n is the number of internal nodes. Let us see following for example
             o
        /    |    \
      o      o      o
   / | \          / | \
  o  o  o        o  o  o
                  / | \
                 o  o  o

k = 3
Number of internal nodes n = 4
Number of leaf nodes = (k-1)*n  + 1
                     = (3-1)*4 + 1
                     = 9 
Question 6

The maximum number of binary trees that can be formed with three unlabelled nodes is:

Cross

1

Tick

5

Cross

4

Cross

3



Question 6-Explanation: 

Certainly, here's the revised presentation of the unlabeled binary trees:

 

Note that nodes are unlabeled. If the nodes are labeled, we get more trees. We can find the number of binary tree by Catalan numbers. Here n = 3 Number of binary tree = (2nCn)/ n+1 = (2*3C3)/ 3+1 = 5. So, option (B) is correct.

Question 7

The number of leaf nodes in a rooted tree of n nodes, with each node having 0 or 3 children is:

Cross

n/2

Cross

(n-1)/3

Cross

(n-1)/2

Tick

(2n+1)/3



Question 7-Explanation: 

In a tree with nodes, some having 0 or 3 children:

Let's call:
n - as the total number of nodes.
L -the number of leaf nodes.
I - as the number of internal nodes.

Now, here's the deal: each internal node with 3 children gives us 2 internal nodes and 1 leaf node. The root node doesn't play a role here, so we can say (L = 2I + 1).

And we know that the total number of nodes n is just the sum of leaf nodes L and internal nodes I: n = L + I

Now, if we substitute the L value from the first equation into the second one, we get n = (2I + 1) + I, which simplifies to n = 3I + 1.

Solving this for I, we find I = (n-1)/3

Now, plug this back into the L equation, and we get L = 2((n-1)/3) + 1, which simplifies to L = (2n+1)/3.

So, in simple terms, the number of leaf nodes L in a tree with nodes having 0 or 3 children is (2n+1)/3.

Question 8

A weight-balanced tree is a binary tree in which for each node. The number of nodes in the left sub tree is at least half and at most twice the number of nodes in the right sub tree. The maximum possible height (number of nodes on the path from the root to the farthest leaf) of such a tree on n nodes is best described by which of the following? a) log_2 n b) log_{4/3} n c) log_3 n d) log_{3/2} n

Cross

A

Cross

B

Cross

C

Tick

D



Question 8-Explanation: 

A weight-balanced tree is a binary tree where the number of nodes in the left subtree is at least half and at most twice the number of nodes in the right subtree for each node. To determine the maximum possible height of such a tree on n nodes, let's analyze the options:

a)  This represents the height of a perfectly balanced binary tree. In a weight-balanced tree, the left subtree can have at most twice the number of nodes in the right subtree, so it won't necessarily be perfectly balanced. Therefore, option a is not the best description.

b)This option seems to be a non-standard logarithmic base. It's not a common logarithmic base used in tree height analysis. It is not a typical representation for the height of a binary tree.

c) This represents the height of a perfectly balanced ternary tree. Similar to option a, this doesn't consider the constraints of a weight-balanced tree.

d)  This option is interesting because it suggests a growth factor in the number of nodes in the left subtree compared to the right subtree. It is a non-standard base but seems to reflect the constraints of a weight-balanced tree.

In a weight-balanced tree, the number of nodes in the left subtree is at least half and at most twice the number of nodes in the right subtree. Therefore, option (d) is the best description of the maximum possible height of a weight-balanced tree on n nodes.

Question 9
A complete n-ary tree is a tree in which each node has n children or no children. Let I be the number of internal nodes and L be the number of leaves in a complete n-ary tree. If L = 41, and I = 10, what is the value of n?
Cross
6
Cross
3
Cross
4
Tick
5


Question 9-Explanation: 
For an n-ary tree where each node has n children or no children, following relation holds
    L = (n-1)*I + 1
Where L is the number of leaf nodes and I is the number of internal nodes. Let us find out the value of n for the given data.
  L = 41 , I = 10
  41 = 10*(n-1) + 1
  (n-1) = 4
  n = 5
Question 10
The height of a binary tree is the maximum number of edges in any root to leaf path. The maximum number of nodes in a binary tree of height h is:
Cross
2^h -1
Cross
2^(h-1) – 1
Tick
2^(h+1) -1
Cross
2*(h+1)


Question 10-Explanation: 
Maximum number of nodes will be there for a complete tree. Number of nodes in a complete tree of height h = 1 + 2 + 2^2 + 2*3 + …. 2^h = 2^(h+1) – 1
There are 52 questions to complete.

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!


  • Last Updated : 27 Sep, 2023

Share your thoughts in the comments
Similar Reads