Data Structure Flashcards
What does the acronym LIFO mean?
A
Last In First Out
What methods are available on a Stack data structure?
pop() - Pops the “top” value off the stack.
push() - Pushes an item to the “top” of the stack
peek() - Returns the “top” value without modifying it
What must you do to access the value at an arbitrary point in a stack (not just the “top”)
assign the values that are being popped to a variable then peek at the value that needs to be accessed and then push the values that are assigned to a variable back into the stack
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 must the return value of myFunction be if the following expression is possible?
myFunction()();
a function.
in other words the return value of the inner function
What does this code do?
const wrap = value => () => value;
it returns the second function
In JavaScript, when is a function’s scope determined; when it is called or when it is defined?
its determined when and WHERE it is defined
What allows JavaScript functions to “remember” values from their surroundings?
the lexical environment created at the time the function was defined (the closure)