Data structures and graphs

Start questions

Unofficial selected-topic practice.

Practice scope

Original English practice with worked guidance. Selected topics only. This is not a complete syllabus, official past-paper collection or predicted exam score. Check your own exam-board specification: these concepts are not certified against a particular board or exam year. Where a question shows a Cambridge 2027 reference, that is a conceptual placement only; no other exam board (such as Edexcel, AQA or OCR) is mapped, so do not assume this covers your board. Content here is written and checked with AI assistance; it has not been approved by an independent teacher or endorsed by any exam board.

160 original questions across 22 selected topic areas. No account or payment required to practise.

Cambridge International AS & A Level Computer Science (9618), examination year 2027: Conceptual alignment to official sources, not exam-board certification. Syllabus mapping and remaining coverage.

6 questions in this topic

Original questions with indicative worked guidance. Selected topics only.

All topics

Original practice in data structures and graphs; indicative answers for unofficial practice.

6 of 6 questions shown

Loading saved responses

Question 1Hide question3 indicative marks

An empty stack receives PUSH(A), PUSH(B), POP(), PUSH(C), POP(). State the returned values in order and the remaining stack.

Cambridge 2027: Direct conceptual match

Push/pop trace directly manipulates stack data under the AS operational requirement; no A Level stack implementation is elicited.

Conceptual placement only, not official Cambridge endorsement or complete syllabus coverage.

Show indicative guidance

Worked guidance

  1. A stack removes the most recently added unremoved item. Removing B reveals A, then adding and removing C leaves that original A unchanged.

Self-marking points

Tick what your working earned. The count is your own self-assessment.

Self-assessed: not counted yet. This question is worth 3 marks.

Examiner tip

Do not apply FIFO behaviour to a stack.

Question 2Explain why a queue is appropriate for serving print jobs in arrival order and identify the insertion and removal ends.3 indicative marks

Explain why a queue is appropriate for serving print jobs in arrival order and identify the insertion and removal ends.

Cambridge 2027: Direct conceptual match

Print FIFO use and front/rear operations directly justify the listed queue ADT for a scenario.

Conceptual placement only, not official Cambridge endorsement or complete syllabus coverage.

Show indicative guidance

Worked guidance

  1. Maintaining separate ends prevents a new job from overtaking earlier waiting jobs. Priority printing would require a different ordering policy, but the stated arrival-order requirement fits a queue.

Self-marking points

Tick what your working earned. The count is your own self-assessment.

Self-assessed: not counted yet. This question is worth 3 marks.

Examiner tip

FIFO does not by itself promise a maximum waiting time.

Question 3Insert 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 indicative marks

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.

Cambridge 2027: Partial conceptual match

Hashing/probing is relevant to keyed access, but this is an in-memory table, not the random/sequential file read/write context specified in the row.

Conceptual placement only, not official Cambridge endorsement or complete syllabus coverage.

Show indicative guidance

Worked guidance

  1. All keys have remainder three. Linear probing advances to the next slot until an empty one is found, so successive collisions form a cluster without overwriting prior keys.

Self-marking points

Tick what your working earned. The count is your own self-assessment.

Self-assessed: not counted yet. This question is worth 3 marks.

Examiner tip

A collision does not authorise replacing the stored key.

Question 4For 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 indicative marks

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.

Cambridge 2027: Board-neutral enrichment

Breadth-first search is not a named required graph search: 18.1 names A* and Dijkstra. Graph ADT familiarity does not establish BFS alignment.

Conceptual placement only, not official Cambridge endorsement or complete syllabus coverage.

Show indicative guidance

Worked guidance

  1. BFS's queue processes all vertices at one distance before the next distance. Starting at A places B and C at distance one, then discovers D at distance two.

Self-marking points

Tick what your working earned. The count is your own self-assessment.

Self-assessed: not counted yet. This question is worth 3 marks.

Examiner tip

Marking on enqueue prevents duplicate queue entries through different parents.

Question 5A 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 indicative marks

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.

Cambridge 2027: Board-neutral enrichment

Tombstone deletion semantics for an open-addressed table are not explicitly specified; broad hashing/dictionary headings are insufficient direct evidence.

Conceptual placement only, not official Cambridge endorsement or complete syllabus coverage.

Show indicative guidance

Worked guidance

  1. An empty-never-used slot is evidence that no key on that probe chain lies further along; a deleted slot is not. A distinct deleted state preserves that logical distinction.

Self-marking points

Tick what your working earned. The count is your own self-assessment.

Self-assessed: not counted yet. This question is worth 4 marks.

Examiner tip

Search must distinguish never-used from deleted slots.

Question 6Use 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 indicative marks

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.

Cambridge 2027: Direct conceptual match

Dijkstra relaxation gives A-C-B-D weight 4, directly within the named graph-search requirement; graph implementation code is not required.

Conceptual placement only, not official Cambridge endorsement or complete syllabus coverage.

Show indicative guidance

Worked guidance

  1. Initial alternatives for D include the route through C of weight six. Relaxing from improved B gives four, with predecessors D<-B<-C<-A. Nonnegative continuation ensures an unsettled longer prefix cannot later undercut a settled minimum.

Self-marking points

Tick what your working earned. The count is your own self-assessment.

Self-assessed: not counted yet. This question is worth 4 marks.

Examiner tip

For weighted graphs, BFS edge count is not a substitute for minimum total weight.

All AS & A Level subjects