data-structures Flashcards
LIFO?
Last In First Out
what methods are available on a Stack data structure?
peek push pop
what must you do to access the value at an arbitrary point in a stack?
pop repeatedly until the end?
time complexity of stack?
O(n)
What does the acronym FIFO mean?
first in first out
What methods are available on a Queue data structure?
peek, enqueue, dequeue
What must you do to access the value at an arbitrary point in a queue (not just the “front”)?
dequeue from the front until you get the element that we’re looking for
how are linked lists different from an array?
An array is a collection of elements of a similar data type. Linked List is an ordered collection of elements of the same type in which each element is connected to the next using pointers. (sequential)
how would you access an arbitrary node in a linked list (not just the “head”)?
start from the beginning and jump to node to node O(n) linear time