1.Easy
How are the elements of an array stored in memory?
- AIn a tree of memory pages
- BIn random locations chosen by a hash
- CIn one contiguous block, one after another
- DScattered, linked by pointers
2.Easy
What is the load factor of a hash table?
- AThe number of stored elements divided by the number of buckets
- BThe number of buckets divided by the average length of the keys stored
- CThe time needed to load the table from disk
- DThe number of collisions so far
3.Easy
What is a directed graph?
- AA graph whose edges all have weights
- BA graph in which every pair of distinct vertices is joined by an edge
- CA graph whose edges have a direction from one vertex to another
- DA graph that has no cycles
4.Medium
Which abstract data type does Dijkstra's algorithm use to choose the next vertex to process?
- AA set with no ordering
- BA stack
- CA min-priority queue
- DA FIFO queue
5.Medium
An in-order traversal of a binary search tree visits the keys in:
- AInsertion order
- BAscending sorted order
- CDescending order always
- DLevel order
6.Medium
You have a reference to a node in the middle of a list. In which list can you remove it in O(1)?
- AA dynamic array
- BA sorted array
- CA doubly linked list
- DA singly linked list
7.Hard
What guarantee do the red-black tree rules give about the height of a tree with n keys?
- AThe height is at most 2 log2(n + 1)
- BThe height is exactly log2 n
- CThe height is at most log2 n + 1
- DThe height is at most n / 2
8.Hard
Kahn's algorithm for topological sorting repeatedly removes vertices with in-degree 0. Which structure holds those vertices?
- AA max-heap ordered by out-degree
- BA queue (or any collection) of vertices whose in-degree is 0
- CAn adjacency matrix recording which vertices have already been removed
- DA stack of all visited edges
Answer key
- 1. C · In one contiguous block, one after another
- 2. A · The number of stored elements divided by the number of buckets
- 3. C · A graph whose edges have a direction from one vertex to another
- 4. C · A min-priority queue
- 5. B · Ascending sorted order
- 6. C · A doubly linked list
- 7. A · The height is at most 2 log2(n + 1)
- 8. B · A queue (or any collection) of vertices whose in-degree is 0
Full step-by-step solutions: practise this topic on examproblems.com.