data structures Flashcards
what is a queue
an ordered set of items which area added at the tail and removed from the head - fifo
what are the 5 operations needed to use a queue
Queue() - creates an empty queue
dequeue()
enqueue(item)
IsEmpty()
size()
what is an abstract data type
defines a data type logically rather than structurally
data structure
the physical representation of the structure of data being stored in memory
strong encapsulation
completely hides the details on howl the data structure is stored from the user
records
a compound item with components of various different types called fields
what does malloc do
dynamically allocates marmot and return the base location for the allocated space
e.g. student = malloc(sizeof(student));
what is a pro of 2d arrays
very fast access compared to a list using indexing
what are cons of 2d arrays
has a fixed size and doesn’t resize easily (you have to copy the contents into a bigger array)
insertions and deletions can be costly
what is a stack
adt - filo
bounded stacks
have a max size
stack overflow
trying to push when the stack is full
stack underflow
trying to pop when the stack is empty
what are some common applications for stacks
function calls
depth first search
evaluating expressions
braces matching
list
stores a set of items in a linear order