What data structures store collections of data, and how do stacks, queues, linked lists, trees and hash tables differ?
Data structures: arrays, records, tuples and lists, the stack and queue abstract data types and their operations, linked lists, trees and graphs, and hash tables, including how each is used and its advantages.
An OCR H446 answer on data structures: arrays, records, tuples and lists, the stack and queue abstract data types with their operations, linked lists, trees, graphs and hash tables, including how each is used and its advantages and disadvantages.
Reviewed by: AI editorial process; not yet individually human-reviewed
Have a quick question? Jump to the Q&A page
Jump to a section
What this dot point is asking
OCR wants the common data structures, arrays, records, tuples, lists, stacks, queues, linked lists, trees, graphs and hash tables, with how each works, its operations and its uses. Expect a "stack versus queue" question and a "how does a hash table work" question.
The answer
Arrays, records, tuples and lists
Stacks and queues
Linked lists, trees, graphs and hash tables
Examples in context
The call stack manages every subroutine call and is why recursion uses memory. Operating-system schedulers and print spoolers use queues. Hash tables back dictionaries and database indexes for fast lookup. Trees structure file systems and binary search trees; graphs model maps and social networks (traversed by BFS and DFS). OCR links this to the searching and traversal algorithms that operate on these structures, and to choosing the right structure when designing the Programming Project.
Try this
Q1. State the order in which items leave a stack and a queue. [2 marks]
- Cue. Stack: last in, first out (LIFO). Queue: first in, first out (FIFO).
Q2. State one advantage of a linked list over an array. [1 mark]
- Cue. It can grow and shrink dynamically, and insertion/deletion just re-links pointers without shifting elements.
Q3. Explain what a collision is in a hash table and one way to handle it. [2 marks]
- Cue. A collision is when two different keys hash to the same index; it can be handled by chaining (a list at that index) or open addressing (probing for the next free slot).
Exam-style practice questions
Practice questions written in the style of OCR exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.
OCR 20206 marksExplain the difference between a stack and a queue, naming the operations on each, and give one use of each in a computer system.Show worked answer →
Stack (up to 3): a stack is a last in, first out (LIFO) structure; items are added (push) and removed (pop) at the same end (the top), and peek reads the top without removing it. Use: storing return addresses and local variables during subroutine calls (the call stack), or implementing undo.
Queue (up to 3): a queue is a first in, first out (FIFO) structure; items are added (enqueue) at the rear and removed (dequeue) from the front. Use: holding processes ready to run (scheduling), a print spooler, or buffering data such as keyboard input. Markers reward LIFO with push/pop for the stack, FIFO with enqueue/dequeue for the queue, and a valid use of each.
OCR 20216 marksExplain how a hash table stores and retrieves data quickly, what a collision is, and one way collisions can be handled.Show worked answer →
How it works (up to 3): a hash table applies a hash function to a key to compute an index (the hash) into an array, and stores the item at that index. To retrieve an item, the same hash function is applied to the key to go straight to its index, giving very fast (close to ) lookup, insertion and deletion on average, without searching.
Collisions and handling (up to 3): a collision occurs when two different keys hash to the same index. It can be handled by chaining (storing a list of items at that index) or by open addressing / probing (placing the item in the next free slot). Markers reward hashing the key to an index for near-constant-time access, the definition of a collision (two keys, same index), and one valid resolution method.
Related dot points
- Primitive data types (integer, real/float, Boolean, character, string) and how text is represented using character sets such as ASCII and Unicode, including the size and range implications of each type.
An OCR H446 answer on primitive data types and text representation: the integer, real, Boolean, character and string types and their storage, and how characters are represented in binary using character sets such as ASCII and Unicode, with their size and range implications.
- Mathematical skills for computer science: set theory and set operations, the comparison of binary, denary and hexadecimal magnitudes, simple logic propositions, and the use of these tools to reason about data and algorithms.
An OCR H446 answer on the mathematical skills underpinning computer science: set theory and set operations, comparing magnitudes across binary, denary and hexadecimal, simple logic propositions, and applying these tools to reason about data and algorithms.
- Graph and tree traversal: breadth-first and depth-first traversal of a graph, the pre-order, in-order and post-order traversal of a binary tree, and the shortest-path algorithms Dijkstra's algorithm and A* search.
An OCR H446 answer on traversal and shortest-path algorithms: breadth-first and depth-first graph traversal, the pre-order, in-order and post-order traversal of a binary tree, and how Dijkstra's algorithm and A* search find a shortest path.
- Searching algorithms: linear search, binary search and binary tree search, how each works with a trace, the precondition for binary search, and their time complexity in Big-O notation.
An OCR H446 answer on searching algorithms: how linear search, binary search and binary tree search work with worked traces, the requirement that binary search needs a sorted list, and the time complexity of each in Big-O notation.
- Object-oriented programming techniques in practice: defining classes with attributes and methods, constructors and instantiation, getters and setters for encapsulation, inheritance and method overriding for polymorphism, and the benefits of an object-oriented design.
An OCR H446 answer on object-oriented programming techniques in practice: defining classes with attributes and methods, constructors and instantiation, getters and setters for encapsulation, inheritance with method overriding for polymorphism, and the benefits of object-oriented design.