Data Structures/Closures Flashcards

1
Q

What does the acronym LIFO mean?

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

push(), pop(), peek()

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

loop through and iterate through each element top to bottom until you reach desired element

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

dequeue(), enqueue(value), peek()

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

by using a loop to go through and dequeue elements until you reach the desired element and peek

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

in a linked list the data are stored individually and are ‘linked’ together while arrays hold data together and are accessed using an index

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

you need to go through the entire list from the head node until you reach the desired node

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

What are unit tests?

A

Software where individual units are tested

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

Why is it important to write unit tests?

A

For detecting bugs and refining the code quality

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

What code should be tested with a unit test? What code is not well suited for unit tests?

A

testing functions and components, it is not well suited for larger blocks of code and for frontend stuff

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

What is Jest? What are some other popular JavaScript unit testing frameworks?

A

open-source js testing framework that is used to write unit tests. other testing frameworks include (Mocha, Jasmine, Karma, Ava, etc)

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

In JavaScript, when is scope determined?

A

Before the code is executed

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

What values does a closure contain?

A

the function and the object that contains the variables and params of the outer function that were in scope when the inner function was created

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

When is a closure created?

A

when a function is defined inside another function, and the inner function references a variable from the outer function’s scope

16
Q

How can you tell if a function will be created as a closure?

A
17
Q

In React, what is one important case where you need to know if a closure was created?

A

if you have a function with a dependency