ICC Data Structures and Algorithms 3 — Questions and Answers
Question 1: In a binary search tree (BST), where is the largest value found?
- The root node
- The leftmost node
- The rightmost node (Correct answer)
- Any leaf node
Correct answer: The rightmost node
In a BST, all right children are greater than their parent, so the rightmost node holds the maximum value.
Question 2: What is the maximum number of children a node can have in a binary tree?
- 1
- 2 (Correct answer)
- 3
- Unlimited
Correct answer: 2
By definition, a binary tree node can have at most two children: a left child and a right child.
Question 3: Which graph traversal algorithm uses a queue to visit nodes level by level?
- Depth-First Search (DFS)
- Breadth-First Search (BFS) (Correct answer)
- Dijkstra's Algorithm
- Bellman-Ford
Correct answer: Breadth-First Search (BFS)
BFS uses a queue to explore all neighbors at the current depth before moving to the next level.
Question 4: An AVL tree maintains balance by ensuring the height difference between left and right subtrees is at most:
- 0
- 1 (Correct answer)
- 2
- 3
Correct answer: 1
AVL trees enforce a balance factor of -1, 0, or +1, meaning subtree heights differ by no more than 1.
Question 5: In graph theory, a directed graph where no cycle exists is called a:
- Bipartite graph
- Directed Acyclic Graph (DAG) (Correct answer)
- Weighted graph
- Complete graph
Correct answer: Directed Acyclic Graph (DAG)
A DAG is a directed graph with no cycles, commonly used in task scheduling and dependency resolution.
Question 6: Which tree traversal visits the root node before its left and right subtrees?
- Inorder
- Postorder
- Preorder (Correct answer)
- Level-order
Correct answer: Preorder
Preorder traversal visits the root first, then recursively traverses the left subtree, then the right.
Question 7: What is the height of a perfectly balanced binary tree with 7 nodes?
- 2 (Correct answer)
- 3
- 4
- 6
Correct answer: 2
A complete binary tree with 7 nodes has height 2 (levels 0, 1, and 2), since 2³ - 1 = 7.
In a binary search tree (BST), where is the largest value found?