Data Structures
Advanced Notes
Specification
1.4.2 a)
● Arrays
● Records
● Lists
● Tuples
1.4.2 b)
● Stack
● Queue Arrays, Records, Lists, and Tuples
Arrays
An array is an ordered, finite set of elements of a single type . A 1D (one-dimensional)
array is a linear array . Unless stated in the question, arrays are always taken to be zero-
indexed. This means that the first element in the array is considered to be at position
zero. Below is an example of a one-dimensional array:
________________________________________________________________________
oneDimensionalArray = [1, 23, 12, 14, 16, 29, 12] //creates a
1D array
print(oneDimensionalArray[3])
>> 14
________________________________________________________________________
A two-dimensional array can be visualised as a table or spreadsheet . When
searching through a 2D array, you first go down the rows and then across the columns
to find a given position. This is the reverse to the method used to find a set of coordinates.
Below is an example involving a two-dimensional array.
________________________________________________________________________
twoDimensionalArray = [[123, 28, 90, 38, 88, 23, 47],[1, 23, 12,
14, 16, 29, 12]]
print(twoDimensionalArray)
>> [[23, 28, 90, 38, 88, 23, 47],
Advanced Notes
Specification
1.4.2 a)
● Arrays
● Records
● Lists
● Tuples
1.4.2 b)
● Stack
● Queue Arrays, Records, Lists, and Tuples
Arrays
An array is an ordered, finite set of elements of a single type . A 1D (one-dimensional)
array is a linear array . Unless stated in the question, arrays are always taken to be zero-
indexed. This means that the first element in the array is considered to be at position
zero. Below is an example of a one-dimensional array:
________________________________________________________________________
oneDimensionalArray = [1, 23, 12, 14, 16, 29, 12] //creates a
1D array
print(oneDimensionalArray[3])
>> 14
________________________________________________________________________
A two-dimensional array can be visualised as a table or spreadsheet . When
searching through a 2D array, you first go down the rows and then across the columns
to find a given position. This is the reverse to the method used to find a set of coordinates.
Below is an example involving a two-dimensional array.
________________________________________________________________________
twoDimensionalArray = [[123, 28, 90, 38, 88, 23, 47],[1, 23, 12,
14, 16, 29, 12]]
print(twoDimensionalArray)
>> [[23, 28, 90, 38, 88, 23, 47],