This section contains carefully selected MCQs and Previous Year Questions with explanations to help students understand concepts and prepare effectively for examinations, interviews, and competitive tests.
Q: 1A binary search tree is generated by inserting the following integers
47, 19, 5, 68, 23, 58, 39, 4, 6, 27, 50, 14
The number of nodes in the left sub-tree and right sub-tree of the root are _______ respectively.
Option C
A Binary Search Tree (BST) is a binary tree where:
The first element 47 becomes the root of the Binary Search Tree, and the remaining elements are inserted according to BST rules.
However, it is not always necessary to draw the complete tree, we can simply count the elements such that all values less than the root belong to the left subtree, and all values greater than the root belong to the right subtree.
Left Subtree (< 47):
Right Subtree (> 47):
Q: 2Consider the following array elements A=[4, 1, 3, 2, 16, 9, 10, 14, 8, 7]. The number of interchanges that are necessary to convert the array elements into a max-heap is?
Option B
A Max-Heap is a complete binary tree in which every parent node is greater than or equal to its children.
So, if a parent has children, then:
Heaps are usually stored in an array.
For index i:
So, the given array A = [4, 1, 3, 2, 16, 9, 10, 14, 8, 7] is treated like this tree structure:

“Convert to Max-Heap” means rearranging the given array elements so that they satisfy the properties of a max-heap. In a max-heap, the largest element is always placed at the root (top), and every parent node has a value greater than or equal to its child nodes.
The Build-Max-Heap Algorithm uses a Bottom-Up approach to convert an array into a max-heap. Instead of starting from the root, it begins from the last non-leaf node and moves upward to the root, applying heapify at each step. This approach ensures that smaller subtrees are fixed first before handling their parent nodes.
Leaf Nodes are not processed because they already satisfy the heap property. Only internal nodes may violate the max-heap condition, so they are adjusted.
In an array representation of a max-heap (0-based indexing), the last non-leaf node is found using the formula: ⌊n/2⌋-1, where n is the total number of elements in the heap.
Step-by-Step Process:
Given Array A=[4, 1, 3, 2, 16, 9, 10, 14, 8, 7]
There are 10 elements, so the last non-leaf node is at index: ⌊10/2⌋-1 = 4. So we heapify from index 4 down to 0. Heapify from bottom to top.
Heapify at Index 4 : Value 16
Heapify at Index 3 : Value 2

Heapify at Index 2 : Value 3

Heapify at Index 1 : Value 1

Heapify at Index 0 : Value 4

The total number of interchanges necessary to convert the array into a Max-Heap is 7.
Q: 3The degree of a tree is __________ degree of a node in the tree.
Option A
In a tree, the degree of a node is the number of children (subtrees) that the node has.
The degree of a tree is defined as the maximum degree of any node present in the tree.

| Node | Degree |
|---|---|
| A | 2 |
| B | 2 |
| C | 1 |
| D | 0 |
| E | 0 |
| F | 0 |
The maximum degree among all nodes is 2. Therefore, the degree of the tree is 2.
Q: 4Inorder and postorder traversal of a binary tree are given.
In: E, I, C, F, B, G, D, J, H, K
Post: I, E, F, C, G, J, K, H, D, B
What is the preorder traversal of the binary tree?
Option A
In a Binary Tree:
Given:
In postorder traversal, the last element is always the root. Therefore, Root = B.
Now split Inorder traversal around B.
Now split postorder accordingly.
Left Subtree Postorder:
Right Subtree Postorder:
Construct Left Subtree:
From left subtree postorder, last element is C. So, C becomes left child of B.
In inorder:
E, I | C | F
From Postorder:
Thus, left subtree preorder becomes: C, E, I, F.
Construct Right Subtree:
Right subtree postorder are G, J, K, H, D. Last element is D So D becomes right child of B.
In inorder:
G | D | J, H, K
From postorder:
Thus, right subtree preorder becomes D, G, H, J, K.
Final Preorder Traversal sequence are B, C, E, I, F, D, G, H, J, K.
Q: 5A complete binary tree T have n leaf nodes. What is the number of nodes with degree of 2 in tree T?
Option C
The relation between leaf nodes and nodes having degree 2 is generally derived using the property of a full (strict) binary tree. In such a tree, every internal node has exactly two children.
If L is number of leaf nodes and I is number of nodes with degree 2 then the standard relation is L=I+1.
Given that the number of leaf nodes is n, and using the relation L=I+1, we get n=I+1. Therefore, I=n-1. Hence, the number of nodes with degree 2 is n-1.

Q: 6Consider the following statement:
S1: Ternary search is more efficient than binary search for finding an element in a sorted array.
S2: Worst case deletion and insertion in an AVL tree have same complexity.
Option B
Statement S1: Ternary search divides the array into three parts, while binary search divides it into two parts. Although ternary search reduces the search space into more parts, it requires more comparisons per step than binary search. As a result, binary search is generally more efficient for finding an element in a sorted array. Hence, S1 is incorrect.
Statement S2: In an AVL tree, both insertion and deletion operations may require rebalancing the tree. In the worst case, both operations take O(log n) time because the height of an AVL tree is always logarithmic. Hence, S2 is correct.
Q: 7Preorder traversal of binary search tree is 38, 14, 8, 23, 18, 20, 56, 45, 82, 70. What is the postorder traversal of binary search tree?
Option C
The given preorder traversal is 38, 14, 8, 23, 18, 20, 56, 45, 82, 70. Since this is a Binary Search Tree (BST), we can obtain the inorder traversal by arranging all the elements in ascending order.
So, the inorder traversal is 8, 14, 18, 20, 23, 38, 45, 56, 70, 82.
Now, we have both traversals:
In preorder, the first element is always the root, so 38 is the root. Using 38 in the inorder sequence, we divide the tree into:
For the left subtree, the preorder sequence is 14, 8, 23, 18, 20. Its root is 14. Following the same process gives the postorder sequence is 8, 20, 18, 23, 14.
For the right subtree, the preorder sequence is 56, 45, 82, 70. Its root is 56, giving the postorder sequence is 45, 70, 82, 56.
Finally, postorder traversal follows: Left Subtree → Right Subtree → Root. Therefore, 8, 20, 18, 23, 14, 45, 70, 82, 56, 38 is postorder traversal sequence.
The Binary Search Tree (BST) constructed from the given preorder sequence is shown below:

Q: 8How many edges does a spanning tree of a graph with N vertices have?
Option B
A spanning tree is a subgraph of a connected graph that includes all the vertices but only enough edges to keep the graph connected without forming any cycles.
Q: 9In a binary search tree, which subtree of a node contains elements that are greater than the node’s value?
Option B
A Binary Search Tree (BST) is a special type of binary tree where the arrangement of elements follows a strict rule:
This property allows fast searching, because at each step, the tree decides whether to go left (for smaller values) or right (for larger values).
Q: 10Which statement(s) is/are correct regarding node N deletion in Binary Search Tree?
I. If node N has no children, then just replace location of N in the parent node by the null pointer.
II. If node N has two children, then replace it by preorder successor.
Option A
Deletion of a node in a Binary Search Tree (BST) depends on the number of children that the node has. There are three main cases:
Thank you so much for taking the time to read my Computer Science MCQs section carefully. Your support and interest mean a lot, and I truly appreciate you being part of this journey. Stay connected for more insights and updates! If you'd like to explore more tutorials and insights, check out my YouTube channel.
Don’t forget to subscribe and stay connected for future updates.