AS5 Flashcards
1
Q
Data Structure
A
- A data structure is a collection of related items held together in memory.
2
Q
Static Structures
A
- Size is set at beginning of program.
- Size cannot be changed.
- Inefficient use of memory.
- Easy to program.
- Programmer will know how much space they take up.
3
Q
Dynamic Structure
A
- Size is not set.
- Can expand or shrink as needed.
- Efficient use of memory.
- Harder to implement (need to keep track of size.)
- Not held in contiguous memory. (Each element contains pointer to next element.)
4
Q
Array
A
An array stores a sequence of variables that are all of the same type, grouped under one identifier.
- Normally static.
- Individual values are indexed.
- Can be multidimensional.
- Holds elements of the same type.
- Can iterate through.
5
Q
List
A
- A list is dynamic as its size can change on execution.
- New elements can be easily added and removed by changing pointers.
6
Q
Two-Dimensional Array
A
- Visualised as a grid with rows and columns.
- An array of arrays.
- The position of an element is referred to by two indices rather than one.
- In Python, each element can be accessed by using a nested loop.
7
Q
Searching an array
A
- Arrays are usually immutable (can’t increase their size once created).
- It isn’t possible to remove elements, but you can set them as null.
- Then search for empty spaces and put new data there.
8
Q
Records
A
- A set of items all related to a single entity.
- May contain items of more than one data type.
- Can be multidimensional.
- Fixed size.
- Cannot iterate through a single record.
9
Q
Dictionaries
A
- Used to create record structures in Python.
- Consists of two objects: a key and values.
- The key identifies the element, the value is the corresponding data.
- The key is unique.