Computer Science
Data structures and graphs
- 1.
An empty stack receives PUSH(A), PUSH(B), POP(), PUSH(C), POP(). State the returned values in order and the remaining stack.
[3 marks] · no calculator - 2.
Explain why a queue is appropriate for serving print jobs in arrival order and identify the insertion and removal ends.
[3 marks] · no calculator - 3.
Insert keys 10, 17 and 24 into an empty size-7 hash table using h(k)=k mod 7 and linear probing, zero-based slots. State their final slots.
[3 marks] · no calculator - 4.
For an undirected graph with edges A-B, A-C, B-D and C-D, perform BFS from A, enqueueing unvisited neighbours alphabetically and marking on enqueue. Give visit order and shortest A-to-D edge count.
[3 marks] · no calculator - 5.
A hash table uses linear probing and search stops at an empty slot. Explain why deleting a key by simply clearing its slot can break search, and how tombstones address this.
[4 marks] · no calculator - 6.
Use Dijkstra's algorithm from A on an undirected graph: A-B=4, A-C=1, C-B=2, B-D=1, C-D=5. Determine the shortest A-to-D path and explain why the algorithm requires nonnegative edge weights.
[4 marks] · no calculator
Marking points are indicative, not an official mark scheme. Accept equivalent valid methods and supported interpretations that address the task; award each mark once without requiring the model wording.