1.Easy
What is a weighted graph?
- AA graph in which each edge has a numeric value such as a cost or distance
- BA graph with more edges than vertices
- CA graph in which some vertices are heavier than others because they have more edges
- DA graph that is stored on disk
2.Easy
Which structure is typically used to implement a priority queue?
- AA heap
- BA singly linked list without order
- CA stack
- DA string
3.Easy
What is a directed graph?
- AA graph whose edges all have weights
- BA graph whose edges have a direction from one vertex to another
- CA graph that has no cycles
- DA graph in which every pair of distinct vertices is joined by an edge
4.Medium
What is the value of the postfix expression 3 4 + 2 * ?
- A14
- B24
- C10
- D11
5.Medium
Why is traversing an array often much faster in practice than traversing a linked list of the same length?
- ALinked lists always store elements on disk
- BArray traversal is O(1) in total, while linked list traversal is O(n)
- CArrays use fewer instructions to compare values
- DArray elements are contiguous, so they make good use of the CPU cache
6.Medium
How is a new element inserted into a binary heap?
- ARebuild the whole heap from scratch
- BPlace it at the root and sift it down
- CPlace it at the end of the array and sift it up while it violates the heap property
- DInsert it at its sorted position by shifting all of the larger elements one place right
7.Hard
Why might a server choose its hash function at random from a universal family?
- ATo guarantee that no two keys can ever collide, whatever keys an attacker sends
- BTo make the hash table sorted
- CTo remove the need to resize the table
- DTo make it very unlikely that an attacker can pick many keys that all collide
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 stack of all visited edges
- CAn adjacency matrix recording which vertices have already been removed
- DA queue (or any collection) of vertices whose in-degree is 0
Answer key
- 1. A · A graph in which each edge has a numeric value such as a cost or distance
- 2. A · A heap
- 3. B · A graph whose edges have a direction from one vertex to another
- 4. A · 14
- 5. D · Array elements are contiguous, so they make good use of the CPU cache
- 6. C · Place it at the end of the array and sift it up while it violates the heap property
- 7. D · To make it very unlikely that an attacker can pick many keys that all collide
- 8. D · A queue (or any collection) of vertices whose in-degree is 0
Full step-by-step solutions: practise this topic on examproblems.com.