1.4.2 Data structures - Arrays Flashcards
(10 cards)
1
Q
Define an array
A
- a static, mutable, ordered collection of items
- items can be changed or replaced
- can only store one data type
2
Q
Define a list
A
- a dynamic, mutable, ordered collection of items
- items can be changed or replaced
- can store more than one data type
3
Q
Define a tuple
A
- a static, immutable, ordered collection of items
- items cannot be changed or replaced
- can store more than one data type
4
Q
Define a linear array
A
A one-dimensional array
5
Q
How can you visualise a two-dimensional array?
A
- as a spreadsheet
- a table with two sets of indexes (one for rows and one for columns)
6
Q
How can you visualise a three dimensional array?
A
As a multi-page spreadsheet
7
Q
Define a record data structure
A
- a collection of related fields
- a field is a variable
- each field in a record can have a different data type
8
Q
How many data types can arrays support?
A
A single data type (homogeneous)
9
Q
Differences between arrays and lists
A
- lists can store data non-continuously whereas arrays store data in order
- lists can store data of more than one data type
10
Q
Difference between tuples and arrays
A
- tuples are initialised with regular brackets
- arrays are initialised with square brackets