Algorithm Book - Chapter 3 - Arrays Flashcards

1
Q

What are array inspection functions?

A

min(arr), max(arr), sum(arr), avg(arr)

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

What scenarios are arrays good for? not good for?

A

Arrays are good for random-access and to be read in a differen roder than they were added. Arrays are less suitable (still common) in scenarios with many insertsiona d removals.

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

Arrays can be sparse? explain

A

You can push values at arr.length +1..the value at arr.length would be undefined.

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

Describe passing by reference

A

Arrays are passed by reference. This means that a pointer is sent when an array is sent as an argument. Therefore, even though parameters are always copies of originals, with arrays (and all objects) a pointer is copied, resulting in caller and callee both having a copy of the same pointer. Hence both are looking at the same location in memory, and hence both will reference the same array. When you pass an array to a function, that array is “live”: changes the callee makes in that array will be reflected when we return to the caller, regardless of whether the called function returns that array.

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

Javascript is loosely written

A

Because of it’s data types. JavaScript considers almost everything an object, since almost every possible values has a set of methods attached (valueOf, toString, etc.)

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

What are the data types?

A

Boolean, Number, String, Object, Function, and undefined.

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

Describe falsey and truthy

A

Six values are nothing: false, 0, NaN, “”, null, undefined

Truthy: objects, functions, non-0 numbers and non-empty strings

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