Data Structures

Trees — Practice MCQs for CCAT

20 Questions Section B: Programming Data Structures

Practice 20 Trees multiple-choice questions designed for CDAC CCAT exam preparation. Click "Show Answer" to reveal the correct option with detailed explanation.

Q1.
Maximum nodes at level k in binary tree:
Ak
B2k
C2^k
D2^(k+1)
Show Answer & Explanation

Correct Answer: C — 2^k

At level k (0-indexed), max nodes = 2^k. Level 0 has 1, level 1 has 2, etc.

Q2.
A binary tree with n nodes has __ NULL pointers:
An
Bn+1
Cn-1
D2n
Show Answer & Explanation

Correct Answer: B — n+1

A binary tree with n nodes has n+1 NULL pointers.

Q3.
Height of complete binary tree with n nodes:
An
Blog n
C
Dn/2
Show Answer & Explanation

Correct Answer: B — log n

Height of complete binary tree is O(log n).

Q4.
Inorder traversal of BST gives:
ARandom order
BSorted order
CReverse sorted
DLevel order
Show Answer & Explanation

Correct Answer: B — Sorted order

Inorder traversal of BST gives elements in sorted (ascending) order.

Q5.
In BST, search operation takes:
AO(1)
BO(n)
CO(log n) average
DO(n²)
Show Answer & Explanation

Correct Answer: C — O(log n) average

BST search is O(log n) on average, O(n) worst case (skewed tree).

Q6.
AVL tree is:
AUnbalanced BST
BSelf-balancing BST
CNot a binary tree
DGeneral tree
Show Answer & Explanation

Correct Answer: B — Self-balancing BST

AVL tree is a self-balancing BST where height difference of subtrees ≤ 1.

Q7.
Level order traversal uses:
AStack
BQueue
CArray
DLinked List
Show Answer & Explanation

Correct Answer: B — Queue

Level order (BFS) traversal uses queue.

Q8.
The root of a tree has:
ANo parent
BOne parent
CTwo parents
DMultiple parents
Show Answer & Explanation

Correct Answer: A — No parent

Root is the topmost node with no parent.

Q9.
A tree with n nodes has __ edges:
An
Bn-1
Cn+1
D2n
Show Answer & Explanation

Correct Answer: B — n-1

A tree with n nodes always has exactly n-1 edges.

Q10.
Full binary tree means:
AAll levels filled
BEvery node has 0 or 2 children
CMaximum nodes
DNo leaves
Show Answer & Explanation

Correct Answer: B — Every node has 0 or 2 children

In full binary tree, every node has either 0 or 2 children.

Q11.
Complete binary tree has:
AAll levels completely filled
BAll levels filled except possibly last, filled left to right
COnly left children
DOnly right children
Show Answer & Explanation

Correct Answer: B — All levels filled except possibly last, filled left to right

Complete binary tree has all levels filled except possibly the last, which is filled from left to right.

Q12.
Perfect binary tree has:
AAll internal nodes have 2 children and all leaves at same level
BOnly one child per node
CRandom structure
DNo leaves
Show Answer & Explanation

Correct Answer: A — All internal nodes have 2 children and all leaves at same level

Perfect binary tree has all internal nodes with 2 children and all leaves at the same level.

Q13.
Preorder traversal visits nodes in order:
ALeft, Root, Right
BRoot, Left, Right
CLeft, Right, Root
DRight, Left, Root
Show Answer & Explanation

Correct Answer: B — Root, Left, Right

Preorder: Root first, then Left subtree, then Right subtree (Root-Left-Right).

Q14.
Postorder traversal visits nodes in order:
ALeft, Root, Right
BRoot, Left, Right
CLeft, Right, Root
DRight, Root, Left
Show Answer & Explanation

Correct Answer: C — Left, Right, Root

Postorder: Left subtree first, then Right subtree, then Root (Left-Right-Root).

Q15.
Minimum height of binary tree with n nodes:
An
Bn-1
Cfloor(log2(n))
Dn/2
Show Answer & Explanation

Correct Answer: C — floor(log2(n))

Minimum height is achieved in complete binary tree: floor(log2(n)).

Q16.
Red-Black tree guarantees:
AO(1) operations
BO(log n) worst case operations
CO(n) search
DUnbalanced structure
Show Answer & Explanation

Correct Answer: B — O(log n) worst case operations

Red-Black tree is self-balancing, guaranteeing O(log n) for search, insert, delete.

Q17.
B-tree is commonly used in:
ARAM storage
BDatabase indexing and file systems
CNetwork routing
DString matching
Show Answer & Explanation

Correct Answer: B — Database indexing and file systems

B-trees are optimized for disk access and widely used in databases and file systems.

Q18.
Lowest Common Ancestor (LCA) of two nodes is:
ARoot always
BDeepest node that is ancestor of both
CLeftmost common node
DRightmost common node
Show Answer & Explanation

Correct Answer: B — Deepest node that is ancestor of both

LCA is the deepest (lowest) node that has both given nodes as descendants.

Q19.
Binary heap is used to implement:
AStack
BQueue
CPriority Queue
DHash table
Show Answer & Explanation

Correct Answer: C — Priority Queue

Binary heap efficiently implements priority queue with O(log n) insert and extract.

Q20.
Threaded binary tree uses NULL pointers to store:
ARandom values
BInorder predecessor/successor
CLevel order info
DDepth info
Show Answer & Explanation

Correct Answer: B — Inorder predecessor/successor

Threaded binary tree uses NULL pointers to store inorder predecessor or successor for efficient traversal.