1.Easy
In a tree, what are sibling nodes?
- ANodes that share the same parent
- BNodes that have no children
- CA node and its parent
- DNodes at the same depth in different subtrees
2.Easy
In which order does a postorder traversal of a binary tree visit nodes?
- ARight subtree, then node, then left subtree
- BLeft subtree, then node, then right subtree
- CLeft subtree, then right subtree, then node
- DNode, then left subtree, then right subtree
3.Easy
In an undirected graph, what is the degree of a vertex?
- AIts position in the adjacency list
- BThe number of vertices in the graph
- CThe number of edges connected to it
- DThe length of the longest path from it
4.Medium
Which data structure is used by depth-first search (iterative version)?
- AA hash table only
- BA heap
- CA stack
- DA queue
5.Medium
In a binary min-heap stored in an array (index starting at 0), the children of the node at index i are at:
- A2i and 2i + 1
- Bi/2 and i/2 + 1
- C2i + 1 and 2i + 2
- Di + 1 and i + 2
6.Medium
What is the cost of inserting an element in the middle of an array of n elements?
- AO(log n), because of binary search
- BO(n²), because each element moves n times
- CO(n), because later elements must shift
- DO(1), because the index is known
7.Hard
Which property must a red-black tree satisfy?
- AEvery path from a node to its descendant leaves has the same number of black nodes
- BThe root must be red
- CEvery red node must have red children, so red nodes always form unbroken chains to the leaves
- DEvery node must be red
8.Hard
In the BST with root 50, left subtree 30 (children 20, 40) and right subtree 70 (children 60, 80), the root is deleted using the in-order successor. Which key becomes the new root?
- A80
- B40
- C60
- D70
Answer key
- 1. A · Nodes that share the same parent
- 2. C · Left subtree, then right subtree, then node
- 3. C · The number of edges connected to it
- 4. C · A stack
- 5. C · 2i + 1 and 2i + 2
- 6. C · O(n), because later elements must shift
- 7. A · Every path from a node to its descendant leaves has the same number of black nodes
- 8. C · 60
Full step-by-step solutions: practise this topic on examproblems.com.