DSA Flashcards
What does the acronym LIFO mean?
last in first out
What methods are available on a Stack data structure?
push
pop
peek
print
What must you do to access the value at an arbitrary point in a stack (not just the “top”)?
pop until you get to that point
What does the acronym FIFO mean?
first in first out
What methods are available on a Queue data structure?
dequeue
enqueue
peek
print
What must you do to access the value at an arbitrary point in a queue (not just the “front”)?
dequeue until you get there
How are linked lists different from an array?
sequential access - need to start at beginning and jump from node to node until you get there
does not need to be mutated to scan contents (unlike queues and arrays)
Scott’s answer:
array - 1 data structures, to add, must mutate
linked list - multiple data structure; can add nodes without mutating
How would you access an arbitrary node in a linked list (not just the “head”)?
list.next.next.next
.next until you get to the item you’re looking for
linked list