Array?
A data structure that holds several elements of the same data type
How and why are arrays used in computer hardware?
Contents of arrays are stored contiguously on the RAM
Each position is directly accessible
Values are mutable
Mutable?
Can be changed while the program is running
2D arrays?
Can be visualized as a table
Navigate down the rows then across the columns
3D arrays?
Can be visualized as a multipage spreadsheet / multiple 2D arrays
Pros of using arrays?
Arrays can be declared via a single identifier
Arrays can be processed efficiently, using iteration techniques
Record?
A data structure that consists of a fixed number of variables, called fields.
List?
An abstract data structure that describes a linear collection of data items in an order.
What are the 4 list operations?
Create
Add
Delete
Traverse
How do you implement lists using static arrays?
Create an array where the max number of elements in the list is fixed.
Populate the array sequentially, using a linear search to find gaps
An index pointer is used to point to the next occupied element in the list
Cons of static list implementation?
If items are constantly added/removed there will be gaps
Gaps are found using linear search, which’s slow and inefficient, especially with larger lists.
What does it mean for a list to be dynamic?
The size of the list can change at any time
How do you implement a list dynamically?
Using a linked list
What is a linked list?
A dynamic data structure that acts like a chain, consisting of a sequence of nodes, where each node contains data and a pointer to the next node in the sequence
Node?
An element in a linked list that stores:
Data relating to the element
A pointer to the next node
The head pointer?
Indicates the first element in the linked list
This has a null value when the list is empty
Tail pointer?
Indicates the last element in the linked list
Always points to a null value- marking end of list
Tuple?
An immutable, ordered sequence of elements
Use of tuples?
To group together a set of disparate items, that are to be passed into a method.
Results from SQL queries are received as tuples
Stack?
An abstract LIFO data structure that holds an ordered, linear sequence of items
Main stack operations?
push(data) = adds element to the top of the stack
pop() = removes element from the top of the stack
peek() = returns a copy of the element on the top of the stack
is_empty() = checks if stack is empty
is_full() = checks if stack is full, if it’s in a static structure
Queue?
First in first out data structure that holds an ordered linear sequence of items
Meaning items are added to the end and removed from the front
What’s a pointer?
An object that stores a memory address
Queue overflow?
Enqueuing to a full queue