Data Structure Flashcards

1
Q

What does the acronym LIFO mean?

A

A
Last In First Out

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What methods are available on a Stack data structure?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What must you do to access the value at an arbitrary point in a stack (not just the “top”)

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does the acronym FIFO mean?

A

First In First Out

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What methods are available on a Queue data structure?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What must you do to access the value at an arbitrary point in a queue (not just the “front”)?

A

Dequeue until you reach desired value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How are linked lists different from an array?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How would you access an arbitrary node in a linked list (not just the “head”)?

A

Start at the head and traverse through with the next property

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What must the return value of myFunction be if the following expression is possible?
myFunction()();

A

a function.
in other words the return value of the inner function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What does this code do?
const wrap = value => () => value;

A

it returns the second function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

In JavaScript, when is a function’s scope determined; when it is called or when it is defined?

A

its determined when and WHERE it is defined

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What allows JavaScript functions to “remember” values from their surroundings?

A

the lexical environment created at the time the function was defined (the closure)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly