Alg Qs Flashcards

1
Q

Fastest way to sum up number 1 to n

A

n * ( n + 1 ) / 2

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

Sum for the first n terms in an arithmetic series

A

n(a1 * a2) / 2 where a1 is the starting number and a2 is the finishing number

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

What is a JavaScript object?

A

A JS object is a collection of properties, where a property consists of a key value pair. The value can be data or a function.

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

When to use objects?

A

When order doesn’t matter.
When you need fast access /insertion / removal
Constant time O(n) for access, insertion, and removal

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

What is the Big O of searching an object?

A

O(N)

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

What is the Big O of getting an array of entries, keys or values?

A

O(N)

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

What is the Big O of checking if a property exists?

A

O(1)

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