Which data structure should you choose when an array is not the right shape for the data?
Describe and implement the data structures used in Advanced Higher: one- and two-dimensional arrays, records, sequential files, linked lists, stacks and queues, including their operations.
A focused answer to the SQA Advanced Higher Computing Science content on data structures, covering one- and two-dimensional arrays, records, sequential files, linked lists, stacks and queues with their core operations.
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
The SQA wants you to know the data structures used at Advanced Higher, how each one stores data, and the operations each supports. You should be able to choose the right structure for a problem and write code that uses it, including the two-dimensional array and the dynamic structures (linked list, stack, queue).
Arrays and records
A one-dimensional array stores a fixed number of items of the same type, each reached by an integer index. A two-dimensional array extends this to a grid, where each element is reached by a row index and a column index; it suits tabular data such as a timetable or a marks sheet. A record groups several fields of possibly different types (for example a name, an age and a balance) under one structure, and an array of records is a common way to hold many such entities.
Sequential files
A sequential file stores records on backing storage so data persists between runs. Records are written and read in order from the start of the file; to reach the hundredth record you read past the first ninety-nine. Sequential access suits batch processing of an entire file, such as reading every record to produce a report.
Linked lists
A linked list stores data as a chain of nodes. Each node holds a data item and a pointer (reference) to the next node; the last node points to null. Because nodes are linked by pointers rather than stored side by side, you insert or delete an item by rerouting pointers, without shifting every later item as an array would require. The trade-off is that you cannot jump straight to the nth item; you must follow the chain from the head.
Stacks
A stack is a last-in, first-out (LIFO) structure: you add (push) and remove (pop) only at the top. The most recently added item is the first to leave. Stacks model anything that unwinds in reverse order, such as the return addresses of nested or recursive procedure calls, or an undo history.
Queues
A queue is a first-in, first-out (FIFO) structure: items are added (enqueued) at the back and removed (dequeued) from the front, so they leave in the order they arrived. Queues model fair, ordered waiting, such as a print spooler serving jobs in submission order, or a buffer holding incoming data until it can be processed.
Try this
Q1. State which data structure is last-in, first-out. [1 mark]
- Cue. A stack.
Q2. Give one advantage of a linked list over an array for inserting an item in the middle of the data. [1 mark]
- Cue. Insertion only reroutes a couple of pointers; the array would have to shift every later element along by one.
Exam-style practice questions
Practice questions written in the style of SQA exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.
AH style: stack vs queue4 marksExplain the difference between a stack and a queue, and give one real use of each.Show worked answer →
A stack is last-in, first-out (LIFO): the last item pushed is the first popped (1 mark), used for example to store return addresses for recursive calls or to implement undo (1 mark). A queue is first-in, first-out (FIFO): the first item enqueued is the first dequeued (1 mark), used for example for a print spooler or buffering keystrokes (1 mark). Markers want the LIFO/FIFO ordering correctly matched to each structure and a sensible use for each.
AH style: 2-D array3 marksA 2-D array grades[3][4] stores marks for 3 students across 4 tests. Write pseudocode to find the total mark for student 1 (the second row).Show worked answer →
Initialise a running total to 0 (1 mark). Loop a column index from 0 to 3 over the second row (1 mark). Inside the loop add grades[1][col] to the total (1 mark). For example: SET total TO 0; FOR col FROM 0 TO 3 DO SET total TO total + grades[1][col] END FOR. Markers reward the correct row index (1), the loop over the four columns, and the accumulation into the total.
Related dot points
- Describe and implement object-oriented programming using classes, objects, instantiation, attributes and methods, encapsulation, inheritance, and polymorphism through method overriding.
A focused answer to the SQA Advanced Higher Computing Science content on object-oriented programming, covering classes and objects, instantiation, encapsulation, inheritance and polymorphism through method overriding, with UML class diagrams.
- Describe and implement the standard searching and sorting algorithms (linear and binary search, bubble, insertion and quicksort), explain recursion, and compare algorithm efficiency.
A focused answer to the SQA Advanced Higher Computing Science content on standard algorithms, covering linear and binary search, bubble, insertion and quicksort, recursion, and comparing the efficiency of algorithms.
- Describe and compare iterative (agile) and structured (waterfall) development methodologies, and apply the analysis, design, implementation, testing, documentation, evaluation and maintenance stages of the software development process.
A focused answer to the SQA Advanced Higher Computing Science content on development methodologies, covering iterative agile and structured waterfall approaches and every stage of the software development process from analysis to maintenance.
- Plan and carry out testing using normal, extreme and exceptional data and dry runs with trace tables, and evaluate software for fitness for purpose, robustness, efficiency and maintainability.
A focused answer to the SQA Advanced Higher Computing Science content on testing and evaluation, covering normal, extreme and exceptional test data, dry runs and trace tables, and evaluating software for fitness for purpose, robustness, efficiency and maintainability.
Sources & how we know this
- SQA Advanced Higher Computing Science Course Specification — SQA (2025)
- 2-D array question paper workshop materials — SQA (2024)