The Oh Family Flashcards

1
Q

What do the terms ‘best’, ‘average’ & ‘worst’ mean when it comes to run time?

A

best = the best runtime given the best situation
worst = the worst runtime given the absolute worst situation
average = the general runtime of a general situation

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

What is the definition of big-Oh?

A

f(n) is O(g(n)) if and only if there exists positive constants c and n0, such that:
f(n) <= c x g(n) for all n >= n0

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

What properties does big Oh have?

A

It is reflexive & transitive, but not symmetric

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

What is the multiplication rule for big Oh?

A

If f1(n) is O(g1(n)) & f2(n) is O(g(n)), then there exists positive constants c1, c2, n1, n2.
Let n0 = max(n1, n2), then multiplying gives f1(n) x f2(n) <= c1 x c2 x g1(n) x g2(n) for all n >= n0

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

What is the rule consisting of dropping smaller terms in big Oh?

A

If a function tends towards 0 as n tends towards infinity, then you can effectively ‘discard’ that function from the equation.

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

What are the two ‘rules’ for big Oh?

A

Drop lower-order terms e.g. n if there is an n^2 present
Drop constant terms i.e. numbers such as 5

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

What are the 7 important functions to know for Big Oh?

A

In order of smallest to biggest:
Constant (1)
Logarithmic (log n)
Linear (n)
N-log-N (n log n)
Quadratic (n^2)
Cubic (n^3)
Exponential (2^n)

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

What does it mean by ‘exponents vs powers’?

A

Exponentials grow faster than powers. To cancel out a power, use an exponential e.g. 2^n to cancel n^2

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

What does it mean by ‘powers vs logs’?

A

Powers grow faster than any power of a log. To cancel a log, you use any power, typically n^2, but whatever you have present will do

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

What are some big Oh conventions?

A

Use the smallest ‘reasonable’ possible class of functions
Use the simplest expression of the class

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

What are the other members of the big Oh family?

A

Big Oh (O)
little-oh (o)
Big-Omega (Omega)
Big-Theta (Theta)

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

What is the definition of big-Omega?

A

f(n) is Big-Omega(g(n)) if there are positive constants c and n0 such that:
f(n) >= c g(n) for all n >= n0

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

What are big-Omega’s properties?

A

Reflexive, Transitive, not symmetric

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

What is the definition of big-theta?

A

f(n) is Big-Theta(g(n)) if there are positive constants c, c’ and n0 such that:
f(n) <= c g(n)
f(n) >= c’ g(n)
for all n >= n0

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

What are the properties of Big-Theta?

A

Reflexive, transitive and symmetric

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

What is the definition of little-oh?

A

f(n) is o(g(n)) if for all positive constants (c > 0), there exists n0 such that f(n) < c g(n) for all n >= n0

17
Q

How does the multiplication rule work with big-Oh * little-oh?

A

If f1(n) is O(g(n)) and f2 is o(g(n)), then there exists positive constants c1 > 0 and n1, such that:
Exists c1 > 0 exists n1, f1(n) <= c1 g(n) for all n >= n1
For all c2 > 0, exists n2, f2(n) < c2 g2(n) for all n >= n2
Then multiplying gives:
Exists c1 for all c2, exists n1 exists n2, n0 = max(n1, n2):
f1(n) f2(n) < c1 c2 g1(n) g2(n) for all n >= n0
Hence, f1(n) f2(n) is o(g1(n) g2(n))