Data Structures Flashcards
What does the acronym LIFO mean?
last-in-first-out
What methods are available on a Stack data structure?
push(value) - adds a value to the “top” of the stack
pop() - removes the top value from the stack and returns it
peek() - returns the “top” value of the stack without removing it.
What must you do to access the value at an arbitrary point in a stack (not just the “top”)?
pop() and peek() until you reach that point
What does the acronym FIFO mean?
First In First Out
What methods are available on a Queue data structure?
enqueue(value) - adds a value to the “back” of the queue
dequeue() - removes the “front” value from the queue and returns it
peek() - peeks the “front” value without modifying the queue
What must you do to access the value at an arbitrary point in a queue (not just the “front”)?
Dequeue until you reach desired value
How are linked lists different from an array?
Linked lists are sequential access, where as arrays are random access
Does not need to be mutated to scan it’s contents (queue needs to be mutated)
How would you access an arbitrary node in a linked list (not just the “head”)?
Start at the head and traverse through with the next property
What methods are available on linked lists?
.data - contains the node’s value.
.next a reference to the next node in the list, if there is one. If there is no “next” node in the list, this property is typically set to null.