Skip to main content

Data structures for QCE Digital Solutions Unit 3

Syllabus dot point

“Select and use appropriate data structures, including variables, one-dimensional arrays and lists, and records, to organise and manipulate data within a programmed solution”

QCEDigital SolutionsUnit 3: Digital innovation6 min read

Quick answer

A data structure organises data in memory so a program can use it efficiently; the core structures for Unit 3 are variables (single values), one-dimensional arrays and lists (ordered collections accessed by index), and records or dictionaries (named fields grouped into one item), and you choose between them based on whether the data is single, repeated or compound.

Jump to a section
  1. What this dot point is asking
  2. Variables and primitive types
  3. One-dimensional collections: arrays and lists
  4. Records and dictionaries
  5. Matching the structure to the data
  6. How structures connect to the database
  7. Exam-style questions

What this dot point is asking

QCAA wants you to choose data structures that fit the data a solution handles, then use them correctly in code. The syllabus names variables, one-dimensional collections (arrays and lists) and records as the core structures. A data structure is a way of organising values in memory so the program can store, find and update them efficiently. Picking the wrong structure makes algorithms longer and slower, so this dot point underpins both IA1 design and IA2 implementation.

Variables and primitive types

A variable is a named container for a single value of a given type. The common primitive types are integer, real (float), Boolean, character and string. Choosing the right type matters: storing a phone number as an integer drops leading zeros, so a string is correct. Type also controls which operations are valid, because you can add integers but you concatenate strings.

student_count = 24          # integer
average_mark = 71.5         # real / float
is_enrolled = True          # Boolean
postcode = "4000"           # string, not integer

One-dimensional collections: arrays and lists

When you have many values of the same kind, a single collection is far better than dozens of separate variables. A one-dimensional array or list stores an ordered sequence accessed by a zero-based index. You can loop over it, search it and update individual elements.

marks = [58, 71, 84, 63, 90]
total = 0
for mark in marks:          # iterate the collection
    total += mark
average = total / len(marks)   # 73.2
print(marks[2])                # 84  (index starts at 0)

A list lets you store, traverse and aggregate repeated data with one loop, which is exactly why the accumulator and min/max patterns from the algorithms dot point operate over collections.

Records and dictionaries

A record (often a dictionary in Python) groups several named fields that describe one thing. Where an array holds many values of the same type, a record holds one value of each of several types under field names.

student = {
    "id": 1042,
    "name": "Priya Nguyen",
    "year": 12,
    "enrolled": True
}
print(student["name"])      # Priya Nguyen

Combining the two gives the structure most real solutions use: a list of records, which maps directly onto rows in a database table.

students = [
    {"id": 1042, "name": "Priya", "mark": 84},
    {"id": 1043, "name": "Sam",   "mark": 67}
]
for s in students:
    print(s["name"], s["mark"])
Choosing a structure for a class roll

A solution must store each student's name, ID and three assignment marks. A single variable cannot hold many students, and a flat list of numbers loses which mark belongs to whom. The fit is a list of records: one record per student, with the three marks held in a nested list. This lets you loop the list to process every student, index the record to read a field, and loop the inner list to total the marks. The structure mirrors the data, so the algorithms stay short.

Matching the structure to the data

The selection logic is straightforward:

  • One value that changes over time, use a variable.
  • Many values of the same kind in order, use an array or list.
  • Several named attributes of one entity, use a record or dictionary.
  • Many entities each with attributes, use a list of records.

This choice is part of your IA1 data dictionary and your justification. QCAA expects you to name the structure, state why it suits the data and show it interacting with the user interface and the database.

How structures connect to the database

Data structures in code are the in-memory mirror of the relational tables you design for the databases and SQL dot point. A record maps to a table row, a field maps to a column, and a list of records maps to a result set returned by an SQL SELECT. Designing them to match keeps the data flowing cleanly between the interface, the program and the stored data.

Common traps
  • Off-by-one indexing. A list of length 5 has valid indices 0 to 4; marks[5] is out of range.
  • Parallel arrays instead of records. Keeping names in one list and marks in another and trusting the indices to line up breaks the moment one list is sorted; use a list of records.
  • Wrong type for the data. Postcodes, phone numbers and IDs with leading zeros must be strings, not integers.
  • Mutating while iterating. Removing items from a list inside a loop over the same list skips elements; build a new list instead.
  • Confusing index with value. marks[2] is the third element, not the value 2.

Exam-style questions

Questions in the style of QCAA exam questions on this dot point, each with a worked answer. They are written by ExamExplained unless tagged "Past paper"; the year shows the paper a question is modelled on.

Practice7 marks
A canteen app stores each menu item as a record with name, price and a stock count. Justify the choice of an array of records to hold the full menu, and use pseudocode to symbolise reading the menu and outputting the name and price of every item that is in stock.
Show worked answer →

A 7 mark justify-and-symbolise answer rewards a defended structure choice plus a correct traversal.

Justify: each item has several related fields, so a record groups them as one unit; the menu is a list of like items, so an array (or list) of records stores the whole menu and allows iteration by index. This is more appropriate than parallel arrays, which can fall out of step.

Symbolise the traversal:

FOR i = 0 TO menu.length - 1
    IF menu[i].stock > 0 THEN
        OUTPUT menu[i].name, menu[i].price
    END IF
END FOR

Markers reward the record-plus-array justification, a correct loop over the array, dotted field access, and the in-stock selection.

Practice4 marks
Analyse the difference between a fixed-size array and a list (dynamic array) and recommend which is more appropriate when the number of records is unknown until run time.
Show worked answer →

A 4 mark analyse-and-recommend answer needs the size contrast and a justified choice.

A fixed-size array has its length set when declared, so it is efficient but wastes space if over-sized and fails if the data exceeds it. A list (dynamic array) grows and shrinks at run time, trading a little overhead for flexibility.

When the count is unknown until run time, recommend the list, because it adapts to however many records arrive without risking overflow or wasted capacity. Markers reward the fixed-versus-dynamic distinction and a recommendation justified by the unknown size.

Practise this

Sources & how we know this

ExamExplained