1.Easy
How are the elements of an array stored in memory?
- AIn one contiguous block, one after another
- BIn random locations chosen by a hash
- CIn a tree of memory pages
- DScattered, linked by pointers
2.Easy
What is the max-heap property?
- AEvery left child's key is greater than or equal to its right sibling's key
- BEvery parent's key is greater than or equal to its children's keys
- CThe keys are sorted from left to right
- DAll leaves contain the maximum key
3.Easy
Which operation is O(1) for an array but O(n) for a singly linked list?
- AAccessing the element at index i
- BReading the first element
- CInserting at the head
- DRemoving the head element
4.Medium
A road network has 100,000 junctions, each connected to about 4 others. Which representation is most suitable?
- AA single sorted array of vertices
- BAdjacency matrix
- CA binary heap of edges
- DAdjacency list
5.Medium
A binary tree has root 1 with left child 2 and right child 3; node 2 has children 4 (left) and 5 (right). What is the preorder traversal?
- A1 2 3 4 5
- B4 5 2 3 1
- C4 2 5 1 3
- D1 2 4 5 3
6.Medium
AVL trees and red-black trees guarantee:
- AConstant-time search in every case
- BThat no node has two children
- CO(log n) height through rebalancing
- DThat keys are stored in insertion order
7.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?
- A70
- B80
- C40
- D60
8.Hard
A Fenwick tree (binary indexed tree) over an array of n numbers supports which operations in O(log n)?
- AInserting elements at any position
- BFinding the median in O(1)
- CPrefix-sum queries and single-element updates
- DSorting the array and binary search
Answer key
- 1. A · In one contiguous block, one after another
- 2. B · Every parent's key is greater than or equal to its children's keys
- 3. A · Accessing the element at index i
- 4. D · Adjacency list
- 5. D · 1 2 4 5 3
- 6. C · O(log n) height through rebalancing
- 7. D · 60
- 8. C · Prefix-sum queries and single-element updates
Full step-by-step solutions: practise this topic on examproblems.com.