Binary Tree · Data Structures
35 questions · asked in 17 of 27 years (2000–2026)
MCQ 27 · NAT 81-mark 26 · 2-mark 9
2000Questions per year2026
Questions 16–20 of 35
In a binary tree with n nodes, every node has an odd number of descendants. Every node is considered to be its own descendant. What is the number of nodes in the tree that have exactly one child?
Answer: (A)
Suppose a node has exactly one child. Then its number of descendants is the node itself plus the descendants of that child, which is 1 + odd = even. This goes against the given condition.
So no node in the tree has exactly one child.
Answer: 0
So no node in the tree has exactly one child.
Answer: 0
A binary tree with n>1 nodes has , and nodes of degree one, two and three respectively. The degree of a node is defined as the number of its neighbors.
Starting with the above tree, while there remains a node v of degree two in the tree, add an edge between the two neighbors of v and then remove v from the tree. How many edges will remain at the end of the process?
Starting with the above tree, while there remains a node v of degree two in the tree, add an edge between the two neighbors of v and then remove v from the tree. How many edges will remain at the end of the process?
Answer: (A)
Let the tree have nodes, so it has edges. The degrees add up to twice the number of edges:
Now look at one step. For a node of degree 2 with neighbours and , we remove the 2 edges at and add the edge . So one node and one edge are lost, the degrees of and stay the same, and the graph stays connected, so it is still a tree. Hence the nodes of degree 1 and 3 are never touched.
At the end all degree-2 nodes are gone, so nodes remain. A tree with that many nodes has edges.
Substitute : number of edges .
Answer: (A)
Now look at one step. For a node of degree 2 with neighbours and , we remove the 2 edges at and add the edge . So one node and one edge are lost, the degrees of and stay the same, and the graph stays connected, so it is still a tree. Hence the nodes of degree 1 and 3 are never touched.
At the end all degree-2 nodes are gone, so nodes remain. A tree with that many nodes has edges.
Substitute : number of edges .
Answer: (A)
A binary tree with n>1 nodes has , and nodes of degree one, two and three respectively. The degree of a node is defined as the number of its neighbors.
can be expressed as
can be expressed as
Answer: (B)
The degree of a node is the number of its neighbours.
Total number of nodes:
Use the handshaking lemma:
The sum of all degrees the number of edges.
The number of edges in the graph is always .
Option B
The following three are known to be the preorder, inorder and postorder sequences of a binary tree. But it is not known which is which.
I.MBCAFHPYK
II.KAMCBYPFH
III.MABCKYFPH
Pick the true statement from the following.
I.MBCAFHPYK
II.KAMCBYPFH
III.MABCKYFPH
Pick the true statement from the following.
Answer: (D)
The root is the first item of the preorder sequence and the last item of the postorder sequence. The first items are M (I), K (II) and M (III). The last items are K (I), H (II) and H (III). The only match is K, which is first in II and last in I.
So II is the preorder sequence and I is the postorder sequence. The one left, III, is the inorder sequence. (Check: with root K, inorder III splits into MABC on the left and YFPH on the right, and both parts fit the other two sequences.)
Options (A) and (B) make I a preorder sequence, and (C) leaves the other two sequences unknown. But II is preorder, I is postorder and III is inorder, so only (D) is true.
Answer: (D)
So II is the preorder sequence and I is the postorder sequence. The one left, III, is the inorder sequence. (Check: with root K, inorder III splits into MABC on the left and YFPH on the right, and both parts fit the other two sequences.)
Options (A) and (B) make I a preorder sequence, and (C) leaves the other two sequences unknown. But II is preorder, I is postorder and III is inorder, so only (D) is true.
Answer: (D)
Consider the following C program segment where CellNode represents a node in a binary tree:
struct CellNode
{
struct CellNode *leftChild;
int element;
struct CellNode *rightChild;
};
int GetValue(struct CellNode *ptr)
{
int value = 0;
if (ptr != NULL)
{
if ((ptr->leftChild == NULL) &&
(ptr->rightChild == NULL))
value = 1;
else
value = value + GetValue(ptr->leftChild)
+ GetValue(ptr->rightChild);
}
return(value);
} The value returned by GetValue when a pointer to the root of a binary tree is passed as its argument is:Answer: (C)
The function gives back only when a node has both its left and right child equal to . Such a node is a leaf node. So the value goes up by one at every leaf node.
Answer: (C)
Keep practising