Data Structures Flashcards

1
Q

What does the acronym LIFO mean?

A

Last-In-First-Out operations: the last thing pushed onto the stack is the first thing that can be popped 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 of 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

Start at the top and traverse through with the next property

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 operations: the first thing in enqueued onto the queue is the first thing that can be dequeued 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() - returns the “front” value of the queue without removing it

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 get to the point

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

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

A

A function

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

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

A

wrap(1)(); //1
wrap(2)(); //2

Returns the value

wrap(value) {
return () => value;
};

function wrap(value) {
return function() {
return value;
};
};

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

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

A

Defined

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

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

A

Closures

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