What is a static data structure?
A data structure that reserves a fixed amount of memory, specified by the programmer in advance of its use. They store data in consecutive memory locations and do not need to store memory pointers
What is a dynamic data structure?
Data structures that have no fixed size. The memory used grows and shrinks as items are added/removed. They do not store data in consecutive memory locations and require storage for memory pointers
Give two advantages of static data structures over dynamic data structures:
Give two advantages of dynamic data structures:
Is a queue FIFO or LIFO?
FIFO (First in first out)
Describe the four key operations of a queue:
Describe the data structures and pointers used by a linear queue:
Describe the disadvantages of linear queues if you
1. Don’t shuffle down the items
2. If you do
What is the key difference between a circular queue and a linear queue?
What happens to the rear pointer when enqueuing an item to a circular queue?
rear ← (rear + 1) % maxSize
What is a priority queue? Describe how enqueuing works.
Name an algorithm that can be implemented with a priority queue
Dijkstra’s Algorithm
Is a graph static or dynamic?
Dynamic, they can grow and shrink in size
What is a graph?
Graphs are sets of vertices (nodes) and the edges (arcs) that connect them
What is a graph with a high ratio of edges to vertices called?
Dense
What is a graph with a low ratio of edges to vertices called?
Sparse
What is a weighted graph?
A graph that has weights (number values) on each edge
What is a connected graph?
A graph where there is a path between each pair of vertices
Suggest three things that graphs could be used to model
Give two ways to represent graphs:
Adjacency matrix and adjacency list
How do you represent no edge for a weighted graph in an adjacency matrix?
“-” or “∞” (can’t use zero)
How could an adjacency list be implemented if graph is:
1. weighted
2. unweighted?
State two advantages of adjacency lists:
State a disadvantage of using an adjacency list:
Slow to query (e.g. to check the presence of an edge), as each item in the list must be searched sequentially until the desired edge is found