Key Terms
- Array: A collection of elements of the same data type stored under one variable name
- Index: The position number used to access an element in an array (starts at 0)
- 1D array: A single row of elements accessed by one index
- 2D array: A grid of elements accessed by row and column indices
- Record: A data structure that groups related fields of different data types together
- Field: A named piece of data within a record (e.g. name, age, score)
Must-Know Facts
- Arrays are zero-indexed: the first element is at index 0, last is at index length-1
- All elements in an array must be the same data type
- 2D arrays use [row, column] notation โ row first
- Records can store different data types in the same structure
- Record fields are accessed using dot notation:
student1.name - Accessing index 10 in an array of 10 elements causes an error (valid: 0โ9)
Key Concepts
- Declare 1D array:
array scores[10] - Access element:
scores[0] = 85 - Declare 2D array:
array grid[3, 4] - Access 2D element:
grid[1, 2] = "X" - Define record:
record Student ... name: String ... endrecord - Use dot notation:
student1.age = 16
Common Mistakes
- Using 1-based indexing: Arrays are 0-indexed โ the first element is at index 0, not 1; the last element in an array of size 10 is at index 9, not 10
- Accessing an out-of-bounds index: Accessing
scores[10]in an array declared asarray scores[10]causes a runtime error โ valid indices are 0 to 9 - Storing mixed data types in an array: All elements in an array must be the same data type โ use a record if you need to group different types together
- Confusing arrays and records: Arrays store multiple values of the SAME type; records group related fields of DIFFERENT types (e.g. name as string and age as integer)
- Getting 2D array notation wrong: 2D arrays use [row, column] โ row index comes first;
grid[2, 3]means row 2, column 3
This topic summary covers Knowledge Organiser: Arrays and Records within Insertion Sort for GCSE Computer Science. Revise Insertion Sort in 3.1 Fundamentals of Algorithms for GCSE Computer Science with 15 exam-style questions and 10 flashcards. This topic appears regularly enough that it should still be part of a steady revision cycle. It is section 8 of 8 in this topic. Use this topic summary to connect the idea to the wider topic before moving on to questions and flashcards.
Practice questions for Insertion Sort
Which statement best describes how insertion sort works?
Describe how insertion sort works. Your answer should include how the algorithm processes each element.