Big O Notation Flashcards

1
Q

Big O Notation

A
  • counting number of simple operations the computer has to perform
  • allows us to talk about how the runtime of an algorithm grows as the inputs grow
  • worst case scenario
  • doesn’t depend on the hardware (only algorithms)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

counting operations

A

counting each operator

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

f(n) could be linear

A

f(n) = n

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

f(n) could be quadratic

A

f(n) = n^2

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

f(n) could be constant

A

f(n)=1

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

constant

A
  • arithmetic operations
  • variable assignments
  • accessing elements in an array by index or object by key
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

time complexity

A

how to analyze the runtime of an algorithm as the size of the inputs increase

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

space complexity (auxiliary)

A

how much additional memory do we need to allocate in order to run the code in our algorithm

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

constant space

A
  • most primitives (booleans, numbers, undefined, null)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

O(n) space

A
  • strings (where n is string length)

- reference data types (n is length of arrays and number of keys in objects)

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

logarithms or log

A
  • the power to which a number must be raised in order to get some other number
  • roughly measures the number of times you can divide that number by 2 before you get a value that’s less than or equal to one (ex. log(8) = 3)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

log2(8) = 3

A

2 to what power equals 8 (answer: 3 or 2^3 = 8)

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

logarithmic time complexity

A

searching algorithms, efficient sorting algorithms, recursion (sometimes)

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