1.4.4 Organisation and structure of data: Data structures Flashcards

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

What is the difference between a one-dimensional and two-dimensional array?

A

A one-dimensional array is equivalent to a list (like a shopping list) whereas a two-dimensional array is equivalent to a table (like a database or excel spreadsheet).

For those who can visualise multi-dimensional figures in their head, picture a single line of information in a one-dimensional array, and a grid (or matrix if you want to sound cool lol) of information in a two-dimensional array.

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

What is a data structure?

A

A data structure is the way that data is stored in a database or program.

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

What is an array?

A

An array (also known as a list) is a set of data values of the tame type, stored in a sequence in a computer program.

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

How are one-dimensional arrays referenced in code?

A

A definition section:
members = [‘John’, ‘Jane’, ‘Alec’, ‘Mary’, ‘Bob’]

And a reference section (or multiple, your call!):
for i in members: #repeat for every member
print(members[i]) #print the reference itself, where ‘i’ is the member ID

The ID is parallel with the array, for example:
John = members[0], Jane = members[1], Alec = members[2], Mary = members[3] etc.

To conclude, a reference is comprised of the array name, in our case ‘members’, followed by our ID surrounded by square brackets.

members[3] - Our ID number, in this cas referencing Mary (our 4th entry).

This section is confusing. If you are still stuck on this, Bitesize has a good explanation as well as other good sources online.

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

How are two-dimensional arrays referenced in code?

A

A definition section:
scores = [‘John’, ‘37’, ‘89’],
[‘Jane’, ‘24’, ‘75’],
[‘Alec’, ‘31’, ‘69’],
[‘Mary’, ‘19’, ‘72’],
[‘Bob’, ‘46’, ‘91’]

  • *This is in the form Name, Age, Score**
  • *Each row represents an entry.**

And a reference section (or multiple, your call!):
print(score[3][2]) #print the reference itself, in this case printing Mary’s score.

To conclude, a reference is comprised of the array name, in our case ‘scores’, followed by our ID coordinates surrounded by square brackets. The first coordinate defines the row, while the second coordinate defines the column.

members[3] - Entry 3 (our 4th entry),[2]** - Value 2 (our 3rd entry, in this case pulling from the scores).

This section is confusing. If you are still stuck on this, Bitesize has a good explanation as well as other good sources online.

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