Tree MCQ Quiz - Objective Question with Answer for Tree - Download Free PDF
Last updated on Apr 11, 2025
Latest Tree MCQ Objective Questions
Tree Question 1:
Non leaf nodes of B+ tree structure form a :
Answer (Detailed Solution Below)
Tree Question 1 Detailed Solution
The correct answer is Multilevel sparse indices.
Key Points
- Non-leaf nodes of a B+ tree structure form multilevel sparse indices, which are crucial for its efficiency and performance.
- In a B+ tree, all the actual data records are stored in the leaf nodes, while the non-leaf nodes (or internal nodes) store the keys that act as pointers to guide the search process.
- The non-leaf nodes do not store every key, only enough to direct the search to the appropriate leaf node, making the indices sparse.
- This structure helps in reducing the height of the tree, thus speeding up the search, insert, and delete operations.
- Multilevel indexing means that the tree is structured in multiple levels (root, intermediate levels, and leaf nodes), where each level helps narrow down the search space progressively.
- The B+ tree is a balanced tree, meaning all the leaf nodes are at the same level, which ensures consistent and predictable performance.
Additional Information
- B+ trees are widely used in database indexing and file systems due to their efficiency in handling large amounts of data.
- They are an extension of B-trees, with the primary difference being that in B+ trees, all values are stored at the leaf level, and internal nodes only store keys.
- This structure ensures that sequential traversal of the data can be done efficiently by following the linked leaf nodes.
- Because of the multilevel sparse indexing, B+ trees are well-suited for range queries and ordered traversals.
- B+ trees maintain balance by splitting and merging nodes as necessary during insertions and deletions, ensuring that the tree remains balanced with minimal height.
Tree Question 2:
Total number of nodes at the nth level of a full binary tree can be given as __________.
Answer (Detailed Solution Below)
Tree Question 2 Detailed Solution
Explanation:
In a full binary tree, each level contains nodes that follow the pattern:
Level 0: 20 = 1 node
Level 1: 21 = 2 nodes
Level 2: 22 = 4 nodes
...
Level n: 2n nodes
So, the number of nodes at the nth level is given by 2n
Final Answer: Option 3) 2n ✅
Tree Question 3:
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:
Answer (Detailed Solution Below)
Tree Question 3 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 Question 4:
Which of the following algorithms are based on the Breadth First Search (BFS)?
A. Prim's algorithms
B. Kruskal algorithms
C. Dijkstra algorithms
D. Greedy algorithms
E. Dynamic Programming
Choose the correct answer from the options given below:
Answer (Detailed Solution Below)
Tree Question 4 Detailed Solution
The correct answer is Option 4.
Key Points
- Prim's Algorithm:
- Prim's Algorithm is used to find the Minimum Spanning Tree (MST) for a weighted undirected graph.
- It starts from an arbitrary node and explores all the adjacent nodes using BFS to find the edge with the smallest weight that connects the tree to a new vertex.
- It continues this process until all vertices are included in the MST.
- Dijkstra's Algorithm:
- Dijkstra's Algorithm is used for finding the shortest paths between nodes in a graph.
- It starts from the source node and uses BFS to explore all possible paths to other nodes, selecting the path with the smallest cumulative weight.
- It is particularly useful for graphs with non-negative weights.
Additional Information
- Both Prim's and Dijkstra's algorithms rely on the BFS approach to explore nodes level by level, ensuring that the shortest path or smallest weight edge is chosen at each step.
- Prim's Algorithm is specifically used for creating MSTs, whereas Dijkstra's is for shortest path problems.
- While BFS is a fundamental concept, both algorithms incorporate additional logic, such as priority queues, to optimize their respective goals.
Tree Question 5:
Considering above binary tree, what will be the inorder traversal
Answer (Detailed Solution Below)
Tree Question 5 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.
Top Tree 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?Answer (Detailed Solution Below)
Tree Question 6 Detailed Solution
Download Solution PDFConcept:
A binary tree can be traversed in three ways:
- Preorder = (Root, Left subtree, Right Subtree)
- Inorder = (Left subtree, Root, Right Subtree)
- 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:
The height of a tree is the length of the longest root-to-leaf path in it. The maximum and minimum number of nodes in a binary tree of height 5 are
Answer (Detailed Solution Below)
Tree Question 7 Detailed Solution
Download Solution PDFMaximum nodes in Graph with height 5:
Maximum number of nodes = 1 + 2 + 4 + 8 + 16 + 32 = 6
Minimum nodes in Graph with height 5:
Minimum number of nodes = 6
Tips and Tricks:
If nmax is the maximum number of nodes and H height of in a binary search tree, then
nmax = 2H+1 – 1
put H = 5
nmax = 2H+1 – 1 = 26 - 1 = 63
If n is the minimum number of nodes and H is the height of in a binary search tree, then
nmin = H + 1
put H = 5
nmin = 5 + 1 = 6
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 Question 8 Detailed Solution
Download Solution PDFAnswer: 1 to 1
Explanation:
Consider the following Complete Binary Tree
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
Consider the expression tree shown. Each leaf represents a numerical value, which can either be 0 or 1. Over all possible choices of the values at the leaves, the maximum possible value of the
expression represented by the tree is ___.
Answer (Detailed Solution Below) 6
Tree Question 9 Detailed Solution
Download Solution PDFExplanation:
D = h + I = 2, E = G – k = -1, F = l - m =1 and G = n + o = 2
B = 2-(-1) = 3 and C= 1 + 2 = 3
A= 3 + 3 = 6
Final tree:
Hence 6 is the correct answer.
What is the in-order successor of 15 in the given binary search tree?
Answer (Detailed Solution Below)
Tree Question 10 Detailed Solution
Download Solution PDFConcept –
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.
Let T be a binary search tree with 15 nodes. The minimum and maximum possible heights of T are:
Note: The height of a tree with a single node is 0.
Answer (Detailed Solution Below)
Tree Question 11 Detailed Solution
Download Solution PDFConcepts:
Minimum height of the tree is when all the levels of BST are completely filled.
Maximum height of the binary search tree (BST) is the worst case when nodes are in skewed manner.
Formula:
Minimum height of the BST with n nodes is ⌈log2 (n + 1)⌉ - 1
Maximum height of the BST with n nodes is n - 1.
Calculation:
Maximum height of the BST with 15 nodes 15 - 1 = 14
Diagram:
Minimum height of the BST with n nodes is ⌈log2 (15 + 1)⌉ - 1 = 3
Diagram:
What is the sequence of nodes when applying in-order traversal on the binary tree given below?
Answer (Detailed Solution Below)
Tree Question 12 Detailed Solution
Download Solution PDFConcept:
- In-order Traversal: Left -> Root -> Right
- Pre-order Traversal: Root -> Left -> Right
- Post-order Traversal : Left -> Right -> Root
Binary tree:
Inorder Traversal: A, B, C, D, E, F, G, H, I
The maximum height of a binary tree with ‘n’ nodes is _______.
Answer (Detailed Solution Below)
Tree Question 13 Detailed Solution
Download Solution PDFConcept:
In a binary tree, a node can have maximum two children. If there are n nodes in binary tree, maximum height of the binary tree is n-1.
Tree with maximum height: n = 6
Height = 6 – 1 = 5
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 Question 14 Detailed Solution
Download Solution PDFLongest path has length 4.
A binary search tree in which every non-leaf node has non-empty left and right subtrees is called a strictly binary tree. Such a tree with 19 leaves:
Answer (Detailed Solution Below)
Tree Question 15 Detailed Solution
Download Solution PDFFormula:
L = I (n - 1) + 1
where, L = number of leaf nodes
I = number of internal nodes
n = n - ary tree
Explanation:
L = 19
n = 2 (as given tree is strictly binary tree)
19 = I (2 - 1) + 1
I = 18
Number of internal nodes = 18
Number of leaf nodes = 19
Total number of nodes = 18 + 19 = 37
Tips and Trick:
Number of internal node in a binary tree = number leaves - 1 = 19 - 1
Total nodes = number of leaf nodes + internal node = 19 + 18 = 37
Important Point:
Root node is also a internal node.