Wk 1 Asymptotic Notation + Divide/Conquer Flashcards

1
Q

How should each algorithm be described?

A

What is the analogy?
What is the diagram / visual depiction?
What is the example / experience?
What is the plain English explanation?
What is the technical description/pseudo-code?
What is the complexity? Worst-case, Best-case, Avg Case?

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

How is a problem like a language? How does an algorithm relate in this analogy?

A

Every problem is like a language, and with each instance of something we ask whether it fits in my language via the rules of the language. If it does not, we ask, how to I make it so that it would be part of my language?

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

What is the fastest a search problem can be accomplished? Why?

A

lg n. Because it takes that much space to store the parts, and to report the answer.

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

When do we consider an algorithm a good algorithm?

A

When it’s a polynomial function of n (for instance n, lg n)

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

Can a problem itself define an upper bound and or lower bound?

A

yes, for example large primes will be exponential to solved.

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

What is the worst case of insertion sort? Why?

A

n^2

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

What is the important question to ask when wondering if a problem can be solved faster?

A

How much information do I learn on each operation of the algorithm

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

How do lower terms in complexity formulas go away as problem size grows?

A

You take the limit of the complexity as n approaches infinity and lower terms grow slower than higher terms.

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

What three things can you say about functions, just like numbers?

A

….corresponds to big O, etc.

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

Explain in words what big O notation means.

A

Big O notation means that a function is upper bounded by that function. In other words, there exists constants c and n0 such that for all n greater than n0, cg(n) is greater than or equal to f(n).

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

What is the difference between Big O and small o of n?

A

Big O, there exists a constant, and an n0 (“for at least one”). For small o, for every constant, there will be a breakpoint where g(n) > f(n). (“strictly less than”)

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

Explain in words what small O notation means.

A

The function is a strict upper bounds. In other words, for every constant, there will be a break point such that cg(n) is strictly greater than f(n).

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

How does the limit as n approaches infinity of the ratio of f(n) / g(n) change for Big O, small O, big Omega, and small Omega?

A
O = k or 0
o = o
Theta = k
w = infinity
W = k or infinity.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Explain in words Theta notation.

A

There exists two constants and a breakpoint such that for all n’s bigger than the breakpoint, the first constant times g(n) is greater than f(n) and the second constant times g(n) is less than f(n). It is upper and lower bounded by copies of g with different constants.

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

How does W, w relate to O, o?

A

They are the inverse. Same definitions, but different sides of the inequality sign

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

How does Theta relate to O and W

A

A function is Theta if it is O AND W.

17
Q

How does a Divide and Conquer Problem work?

A

Divide Problem into smaller problems.
Solve subproblems
Put them back together

18
Q

How does merge sort use Divide and Conquer?

A

Splits in half
Sorts the half
Puts back together at a time.

19
Q

How does Towers of Hanoi use Divide and Conquer?

A

Move n-1 disks from A to B
Move largest A to C
Move n-1 to C

20
Q

What is complexity of Towers of Hanoi? Why?

A

It’s exponential. 2^n Each step only takes a constant amount of the problem away. (1) and for n subproblems

21
Q

What is the complexity of Merge Sort? Why?

A

n lg n ….see note cards.

22
Q

In English words, how is our complexity of running time affecting in Divide and Conquer strategies?

A

How we choose subproblems matters. The fewer and smaller we can make the subproblems will help. The more subproblems there are, and the bigger the subproblems are, the slower our running time will be.