Data Structure Flashcards
What does the acronym LIFO mean?
Last in, First Out
What methods are available on a Stack data structure?
.pop()
.push()
.peek()
What must you do to access the value at an arbitrary point in a stack (not just the “top”)?’
Use .pop() until you reach the value that you need and put the stack back to where it was
How are linked lists different from an array?
o You can access items sequentially unlike arrays which can be accessed randomly
o They don’t have indexes
o They’re like nested objects
o Real arrays are continuous chunk of arrays, linked lists are spread out
How would you access an arbitrary node in a linked list (not just the “head”)?
Keep using .next() until you reach the node you’re looking for