What is a stack?
A data structure which follows a last in, first out (LIFO) structure
- holds an ordered, linear sequence of items
what is needed to keep track of a stack?
a pointer which points to the top of the stack
what is the operation to add an item to a stack?
push - adds an element to the top of a stack
what is the operation to remove an item from a stack?
pop - removes an element from the top of the stack
what is the peek operation?
returns a copy of the element on the top of the stack without removing it
what are the steps for the push operation?
what are the steps for the pop operation?
what are the steps for the peek operation?
what other functions can there be for a stack?
is_empty - checks if the stack is empty
is_full - checks if the stack is at maximum capacity when stored in a static structure
what is a static data structure?
a data structure of fixed size
what are the ways a stack can be implemented?
what is a queue?
a data structure which follows first in, first out (FIFO) structure
- holds an ordered linear sequence of items
what is the operation to add an item to a queue?
enqueue - adds an element to the queue
what is the operation to remove an item from a queue?
dequeue - removes an element from the front of the queue
what is needed to keep track of a queue?
what other operations can a queue have?
what are the steps for the enqueue operation? (for linear queues)
what are the steps for the dequeue operation? (for linear queues)
what is a circular queue?
a queue which reuses the empty slots at the front of the queue when elements are dequeued
how does a circular queue work?
how is the enqueue operation adjusted for circular queues?
how is the dequeue operation adjusted for circular queues?
what is a priority queue?
a queue where each element in the queue has a priority
when new elements are added into the queue, they are inserted ahead of those with a lower priority and behind those with equal priority.
what is a dynamic data structure?
a data structure where the size can change at any time