Fundamentals of Data Structures Flashcards
Define ‘static data structure’.
A collection of data in memory that has a fixed storage size determined at compile-time.
Define ‘dynamic data structure’.
A collection of data in memory that has the flexibility to grow or shrink at run-time.
Explain two differences between static and dynamic data structures.
Static data structures may waste memory if the number of data items stored is less than the allocated storage space. However, dynamic data structures only take up the amount of storage space required for the actual data.
Static data structures store data in contiguous memory locations, dynamic data structures do not.
Which type of data structure requires a pointer.
Dynamic data structures require memory to store a pointer to the next item which static data structures do not require.
What are the three types of queues?
Priority
Circular
Linear
What type of data structure is a stack
LIFO
Last item in is the first item out
What is an abstract data type?
A system described in terms of its behaviour, without regard to its implementation.
What type of data structure is a queue
FIFO
First item in is the first item out
How many pointers does a queue require?
Two pointers
One for the front of the queue, and another for the back.
How many pointers does a stack require?
One pointer
It points to the top of the stack.
What operations are implemented for a stack?
Push (add item)
Pop (remove item)
Peek (view item)
Describe the algorithm for insertion into a stack.
Check if stack is full.
If the stack is full report an error and stop.
Increment stack pointer.
Insert new data item into location pointed to by stack pointer and stop.
Do the opposite for deletion (empty, decrement). To peek, copy data item from location pointed to by stack pointer.
Describe the algorithm for insertion into a queue.
Check if queue is full.
If the queue is full report an error and stop.
Increment back pointer.
Insert new data item into location pointed to by back pointer and stop.
Describe the algorithm for deletion/reading from a queue.
Check if queue is empty.
If the queue is empty report an error and stop.
Copy data item from location pointed to by front pointer. (reading only)
Increment front pointer and stop. (deletion only)
What are the components of a graph
Vertex
Edge