Chapter 33 - Arrays, tuples and records Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What is an elementary data type?

A

» Integer
» Real
» Boolean
» Char
» String

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are some examples of built-in structured data types such as string, array and record?

A

» String
» Array
» Record

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is an array?

A

» Data structure which contains a set of data of items of the same data type
» Static data structure - size cannot be changed
» Stored contiguously in memory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does it mean by finite?

A

» There is a specific number of elements in the array

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does it mean by ordered?

A

» Implies that there is a first second, third elements of the array

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What position do arrays always start at?

A

» Position 0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is an Index?

A

» A reference that is helpful to reference each element in the array, such as array[0]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How can a 2-D array be visualised as?

A

» Visualised as a table

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How can you refer the elements in the 2-D array?

A

» By their row number then column number
» Such as array[rownumber, columnnumber]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What position in the array is it when the user ask to input row number 1?

A

» Prints the 0th row, as the array starts at 0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How can you make a 2-D array in python?

A

» Array = [[100,200,300],[500,400,200]]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is an important rule when making 2-D arrays in python?

A

» Must always be separated by a comma

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the first element in a 3-D array?

A

» [0,0,0]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a Tuple?

A

» An ordered set of values
» Which could be elements of any type
» Which are immutable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How are Tuples different from arrays?

A

» Unlike arrays, the elements do not all have to be of the same type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What does it mean if a Tuple is immutable?

A

» Its elements cannot be changed
» They are a fixed size set at the point of creation

17
Q

What does a file consist of?

A

» A number of records

18
Q

What does a record contain a number of?

A

» Number of fields holding one item of data

19
Q

What is a record?

A

» Unordered data structure consisting of different data types
» Collection of related fields

20
Q

How can we create an array?

A

» By allocating a contiguous part of memory for the purpose of storing that data

21
Q

What is the definition of contiguous?

A

» Means all the data is stored together

22
Q

How are lists different to array in terms of how items are stored?

A

» Lists are not contiguous

23
Q

What does it mean if a list is heterogeneous?

A

» Can support more than one data type

24
Q

What does it mean if an array is homegeneous?

A

» Can only support a single data type

25
Q

What is a field, in a record?

A

» A variable
» Can have different data types

26
Q

What are the 3 steps to use the record data structure?

A

» Define the record data structure
» Declare a variable or array to use with the record structure
» Assign and retrieve data from the variable record

27
Q

What is the the dot syntax in a record?

A

» recordfield = Assignment

28
Q

What is the differences between arrays list and tuples?

A

» Tuples are immutable whereas lists and arrays are mutable

29
Q

How can you distinguish a list from a tuple?

A

» A list uses [] these brackets
» A tuple uses () these brackets

30
Q

What is a static data structure?

A

» Structure size cannot change at runtime

31
Q

What is a Dynamic data structure?

A

» Structure size can change at runtime