1.5 Data Structures Flashcards
What is an array?
An array is a static data structure that contains variables of the same data type grouped together and each element is referenced by an index.
They can be multidimensional and are random access
What does random access mean?
That if you pick any part of the data structure, you get fetch it in the same amount of time
How would you find and print the contents of an index in a 1D and 2D array in python?
1D
arrayName[row] e.g. subjects[1] = “maths”
2D
arrayName[row][column] e.g. subjects[2][1] = Mrs Lane
What is a record?
A dynamic data structure where the items are referred to by field names instead of an index and the item’s can have different data types. Each field contains different pieces of information about a subject (e.g. a person or building)
What are fixed length records?
Records where each piece of data in each field will be allocated a certain number of bits which can’t be exceeded. If the data is less than the number of bits, there will be blanks.
What are variable length records?
Records where each piece of data will be given the exact amount of bits needed to be stored
What are the advantages and disadvantages of both fixed and variable length records?
Fixed length records
+ The length of each record is known meaning they are easier to manipulate when programming
- Can take up a large amount of space from empty bits
- You can’t go over the limit so some data cannot be inputted
Variable length records
+ They save a lot of storage space
+ Any length data can be inputted into the record
- Can be complicated to manipulate through code as the length is unknown