Revision Notes
AQA A-Level Computer Science (7517): Abstract Data Types and Data Structures – Revision Notes
Condensed AQA 7517 section 4.2.1.4 recall: ADT concept, uses, representations, static versus dynamic, creating and maintaining queues, stacks and hash tables.
- Subject
- Computer Science
- Level
- A LEVELS
- Topic
- Fundamentals of data structures
- Author
- Marlbridge Academic Team
- Updated
- Reviewed by
- Harris Khan (what this means)
Aligned to AQA A Level Computer Science (7517), 2015-onwards. Official specification .
Syllabus page (what it covers and how it is assessed): AQA A Level Computer Science.
Syllabus points this page covers
7517
- 4.2.1.4 Abstract data types/data structures
Found an error? Report a correction.
Need help with this topic? Request a free trial class for A Level Computer Science (7517).
Condensed recall for 4.2.1.4 Abstract data types/data structures, AQA A-Level Computer Science (7517). Worked examples, including a dynamic stack and a hash table trace, are in the abstract data types study guide; exam-style questions are in the abstract data types practice questions.
The four things 4.2.1.4 asks
- Concept and uses of queue, stack, graph, tree, hash table, dictionary, vector; use them in simple contexts.
- How to represent them when a language has no built-in type.
- Static vs dynamic: distinguish, compare uses, advantages and disadvantages.
- Creation and maintenance of data in queues (linear, circular, priority), stacks and hash tables.
ADT in one sentence
An abstract data type is defined by its operations and their behaviour, not by how its data is stored.
Why separate interface from implementation: simpler use; the implementation can be replaced without changing calling code; data can only be changed through valid operations.
Uses
| ADT | Rule or shape | Use |
|---|---|---|
| Queue | FIFO | Print spooling, buffers, scheduling |
| Stack | LIFO | Return addresses, undo, reversing |
| Graph | Vertices and edges | Networks, maps |
| Tree | Connected, undirected, no cycles | Folders, binary search trees |
| Hash table | Key → location by hashing | Fast lookup by key |
| Dictionary | Key-value pairs | Word counts, settings |
| Vector | Ordered numbers from one field | Positions, directions |
Representations without built-in support
queue array + front + rear (+ size) | linked nodes + front/rear refs
stack array + top | linked nodes + top ref
graph adjacency matrix (2-D array) | adjacency list
tree arrays: data, left, right | node records with child refs
hash table array of slots marked empty | array of linked lists
dictionary hash table, or array of records |
vector 1-D array | list or dictionary index → value
STATIC | DYNAMIC
Pointers (array indices) and references (addresses of objects created at runtime) link the parts.
Dynamic stack in four lines
- Push: new node; node.next ← top; top ← node.
- Pop: if top = null, empty; else item ← top.data; top ← top.next.
- Empty test: top = null.
- “Full” only when the heap cannot supply another node.
Static vs dynamic
| Static | Dynamic | |
|---|---|---|
| Size | Fixed at creation | Changes at run time |
| Memory | Reserved in advance; may be wasted | Taken from the heap as needed |
| Overhead | None for pointers | Each item needs space for references |
| Limit | Full at declared size | Heap exhaustion |
| Access | Direct by index | Usually follow references |
| Complexity | Simpler | Harder to implement correctly |
| Suits | Known, stable number of items | Unpredictable, varying numbers |
Creation and maintenance
| Structure | Creation | Maintenance |
|---|---|---|
| Linear queue | Reserve array; front ← 0; rear ← −1; size ← 0 | Test full before add, empty before remove; rear and front only move forward |
| Circular queue | As linear | As linear, but pointers wrap with MOD so freed slots are reused |
| Priority queue | As linear | Insert in priority order (or search for highest priority on removal); equal priorities keep arrival order |
| Stack | Reserve array; top ← −1 | Test full before push, empty before pop or peek; top moves up or down by one |
| Hash table | Reserve array; mark every slot empty | Hash the key; on a collision rehash (for example next slot) until free; retrieve by the same sequence until the key or an empty slot |
Key terms
| Term | Definition |
|---|---|
| Abstract data type | Data type defined by its operations and behaviour, independent of implementation |
| Implementation | The concrete data structure and algorithms that provide the ADT’s operations |
| Static structure | Size fixed when created |
| Dynamic structure | Size changes during execution, using heap memory |
| Heap | Pool of memory from which dynamic structures are allocated at run time |
| Node | Record in a dynamic structure holding data and one or more references |
| Collision | Two keys hash to the same location |
| Rehashing | Finding another location after a collision |
| Clustering | Keys bunching in neighbouring slots, slowing insertion and search |
Exam traps
- An ADT is described by its operations, not “an array”.
- Dynamic does not mean unlimited: the heap can run out.
- Static is often faster to access, not slower.
- Forgetting the full and empty tests when describing maintenance.
- A hash table must mark slots empty at creation, or a failed search cannot stop.
- Dynamic structures use extra memory for references.
Self-test
- Define an abstract data type.
- Give two benefits of separating an ADT’s interface from its implementation.
- How can a graph be represented without a built-in graph type? Give two methods.
- What is stored in each node of a dynamic stack?
- Give the condition for a dynamic stack being empty.
- State one advantage and one disadvantage of a static structure.
- Why might a dynamic structure use more memory per item?
- A shop’s 24 fixed lockers must each record whether they are in use. Static or dynamic?
- What are the initial values of top for an array-based stack and of size for an array-based queue?
- Why must every slot be marked empty when a hash table is created?
- What is a collision, and what is rehashing?
- Name a suitable static representation for a vector.
Answers
- A data type defined by the operations that can be performed on it and their behaviour, independent of how it is stored.
- Any two: code using it is simpler; the implementation can be changed without changing calling code; data can only be altered through valid operations.
- An adjacency matrix and an adjacency list.
- The data item and a reference to the next node (the one below it).
- top = null.
- Advantage: direct access by index or no pointer overhead or simpler to implement. Disadvantage: memory reserved may be wasted, or it cannot grow when full.
- Each item must also store one or more references to other items.
- Static: the number is fixed and known, and each locker can be accessed directly by its number.
- top = −1; size = 0.
- So that inserting and searching can tell an unused slot from a stored key; a search stops when it reaches an empty slot.
- A collision is when two keys hash to the same location; rehashing finds an alternative location, for example the next free slot.
- A one-dimensional array.
More resources on this topic
Related resources
-
Study guides
AQA A-Level Computer Science (7517): Data Structures
Deeper guide to AQA 7517 section 4.2.1.1: what a data structure is, how structures differ, and how to choose and justify one for a practical problem.
Computer Science · AQA · A Level
Read guide -
Study guides
AQA A-Level Computer Science (7517): Dictionaries
Dictionaries for AQA A-Level Computer Science 7517 4.2.7: key-value pairs, operations, implementation and information retrieval, with code and traces.
Computer Science · AQA · A Level
Read guide -
Practice questions
AQA A-Level Computer Science (7517): Dictionaries – Practice Questions
Original AQA A-Level Computer Science 7517 dictionary questions: key-value rules, word counts, Python operations, implementations and code, with answers.
Computer Science · AQA · A Level
Try questions
Get free revision emails (optional)
Occasional emails with practice questions, worked explanations and links to free resources for the qualification and subjects you choose. No spam, and you can unsubscribe from any email. The free tools on this site never need an email.