1.4.2 - Data Structures Flashcards
What is an array?
An ordered, finite set of elements.
What does zero-indexed mean?
The first element in the list is always considered to be at position zero.
What is a 1D array?
A linear array, always taken to be zero indexed.
How can a 2d array be visualised?
A table or spreadsheet.
How do you search through a 2d array?
Go down the rows and then across the columns.
How can a 3d array be visualised?
As a multi-page spreadsheet, made of multiple 2d arrays.
What is a record?
This is a row in a file made up of fields (which can be different types)
What is a list?
It is a data structure made up of a number of ordered items where each item can occur more than once.
Compare lists and arrays?
List values are stored non-contiguously, so they don’t have to be stored next to each other in memory. Additionally, they can contain elements of more than one data type.
What is a tuple?
An ordered set of values of any type. It is immutable, meaning it can’t be changed after created.
What is a linked list?
A dynamic data structure which holds an ordered sequence. The items do not have to be contiguous.
What is a linked list made up of?
A data field containing the value of the actual data.
A pointer field containing the address of the next item in the list.
Pointers containing the index of the first item in the list, and the next available space.
What are some negatives of linked lists?
Nodes are not truly removed from the list, only ignored. This wastes memory.
Storing pointers means more memory is required.
Items are stored in a sequence, so can only be traversed, not directly accessed.
What is a graph?
A set of vertices/nodes connected by edges/arcs.
What are the 3 types of graph?
Directed graph: edges traversed in only one direction. Undirected graph: edges traversed in both directions. Weighted graph: A cost attached to each edge.
Why are adjacency matrixes good?
Convenient to work with because of quicker access times, and easy to add nodes.
Why are adjacency lists good?
More space efficient for large, sparse networks.
What is a stack, and how is it implemented?
It is a LIFO data structure - items can only be added to or removed from it.
It is implemented using a pointer pointing to the top of the stack, where the next data will be inserted.
Where are stacks used?
To reverse an action, such as an undo button.