14: Data Structures Flashcards
What is meant by a static data structure?
Structure size cannot change at runtime
What is meant by a dynamic data structure?
Structure size can change at runtime
What is meant by an immutable data structure?
Structure/data cannot be changed at runtime
What is meant by a mutable data structure?
Structure/data can be changed at runtime
What is a record?
A collection of related fields. A field is a variable, and each field in a record can have a different data type
What is meant by continguous?
All the data is stored together, one element after the other
Are arrays contiguous?
yes
Are lists contiguous?
no
What are the features of an array? (5)
- static
- mutable
- ordered collection of items
- items can be changed or replaced
- can only store one data type
What are the features of a list? (5)
- dynamic
- mutable
- ordered collection of items
- items can be changed or replaced
- can store more than one data type
What are the features of a tuple? (5)
- static
- immutable
- ordered collection of items
- items cannot be changed or replaced
- can store more than one data type
What is a stack?
- A data structure that is essential for the operation of a computer
- Items can be pushed onto the top of the stack when added to it and popped off the top when they are deleted from it
- Known as a LIFO structure
What is meant by a LIFO structure?
- Last-in-first-out
- The last item to be pushed onto the stack must also be the first item to be popped off
What is the purpose of a stack pointer?
Always point to the node at the top
What is a stack overflow?
Any attempt to push an item onto a full stack
What is a stack underflow?
Any attempt to pop an item off an empty stack
How is a stack implemented?
- using an array
- object oriented techniques
What are stacks used for?
- keeping track of user inputs for Undo operations
- Backtracking algorithms - e.g. pathfinding maze solutions
What operations can be performed on a stack?
- Push: Adding an item to the top of the stack
- Pop: Removing an item from the top of the stack
- Peek: Returning a value from the top of the stack without removing it
What is a queue?
- A linear data structure
- items are enqueued at the back of the queue and dequeued from the front of the queue
- Known as a FIFO structure
what is a FIFO structure?
- First-in-first-out
- First item in the queue is the first item to be dequeued
What is the purpose of the back pointer of a queue?
Always points to the last item
What is the purpose of the front pointer of a queue?
Always points to the first item
What is a queue overflow?
An attempt to enqueue an item in a full queue