Skip to main content
EnglandComputer ScienceSyllabus dot point

How do trees, graphs and hash tables organise data, and what are they used for?

Trees, graphs and hash tables: binary search trees and their traversals (in-order, pre-order, post-order), graphs as adjacency matrices and adjacency lists, and hashing for direct-access tables including collision handling.

An Eduqas Component 1 answer on trees, graphs and hash tables: binary search trees and in-order, pre-order and post-order traversals, representing graphs with an adjacency matrix or adjacency list, and hashing for fast direct access with collision handling.

Generated by Claude Opus 4.814 min answer

Reviewed by: AI editorial process; not yet individually human-reviewed

Have a quick question? Jump to the Q&A page

Jump to a section
  1. What this dot point is asking
  2. The answer
  3. Examples in context
  4. Try this

What this dot point is asking

Eduqas wants you to describe binary search trees and their three traversals, represent a graph as an adjacency matrix or adjacency list, and explain hashing and collision handling. These structures organise data for fast search, model relationships, and give near constant-time lookup respectively.

The answer

Binary search trees and traversals

Graphs and their representations

Hash tables and collisions

Examples in context

A BST backs ordered collections where you need both fast search and easy sorted output, such as an index of words. Graphs model road networks for routing, web pages for crawling, and task dependencies for scheduling, which is why the next dot point on traversal algorithms (breadth-first and depth-first) builds directly on this one. Hash tables implement dictionaries, sets, caches and symbol tables in compilers, anywhere you need to look something up by a key almost instantly.

Try this

Q1. State the output order of an in-order traversal of a binary search tree. [1 mark]

  • Cue. Ascending (sorted) order of the keys.

Q2. Give one situation where an adjacency list is preferable to an adjacency matrix. [1 mark]

  • Cue. A sparse graph (few edges relative to vertices), where the list uses far less space than the O(n2)O(n^2) matrix.

Q3. Describe what a collision is in a hash table and name one way to handle it. [2 marks]

  • Cue. Two different keys hash to the same index; handle it by chaining (a linked list per slot) or by open addressing (probe for the next free slot).

Exam-style practice questions

Practice questions written in the style of WJEC Eduqas exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.

Eduqas 20195 marksThe values 50,30,70,20,40,6050, 30, 70, 20, 40, 60 are inserted, in that order, into an initially empty binary search tree. Draw the resulting tree and give the order in which the values are output by an in-order traversal.
Show worked answer →

Build the tree (up to 3 marks): 5050 is the root; 30<5030 < 50 goes left; 70>5070 > 50 goes right; 20<3020 < 30 goes left of 3030; 40>3040 > 30 goes right of 3030; 60<7060 < 70 goes left of 7070. So 5050 has left child 3030 (with children 2020 and 4040) and right child 7070 (with left child 6060).

In-order traversal (up to 2 marks) visits left subtree, node, right subtree, which for a binary search tree outputs the values in ascending order: 20,30,40,50,60,7020, 30, 40, 50, 60, 70.

Markers reward the correctly built tree and the sorted in-order output. The key insight is that an in-order traversal of a BST always yields a sorted sequence.

Eduqas 20214 marksExplain what a hash table is and why it gives fast lookup, and describe one way of dealing with a collision.
Show worked answer →

A hash table stores key-value pairs in an array; a hash function maps each key to an index, so an item can be stored and found by computing its index directly rather than searching (up to 2 marks). This gives near constant-time O(1)O(1) access on average.

A collision occurs when two keys hash to the same index. One method is chaining: each slot holds a linked list and colliding items are appended to that list. An alternative is open addressing: probe to the next free slot (up to 2 marks).

Markers reward the index-from-key idea, why that is fast, and a correct collision-handling method (chaining or probing).

Related dot points

Sources & how we know this