Exam 1 Flashcards

1
Q

Properties of Logs: LogB(xy) is equal to:

A

LogB(x) + LogB(y)

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

Properties of Logs: LogB(x/y) is equal to:

A

LogB(x) - LogB(y)

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

Properties of Logs: Convert LogB(x) To LogA:

A

LogA(x)/LogA(b)

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

Properties of Logs: LogB(x^n) is equal to:

A

nLogB(x)

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

Properties of Logs: x^(LogB(Y)) is equal to:

A

Y^(LogB(x))

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

Master Theorem: What is the formula for master theorem in terms of a, b, and d:

A

T(n) = aT([n/b]) + O(n^d)

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

Master Theorem: According to master theorem, what is the time: if d > logB(a)

A

O(n^d)

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

Master Theorem: According to master theorem, what is the time: if d = logB(a)

A

O(n^d log n)

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

Master Theorem: According to master theorem, what is the time: if d < logB(a)

A

O(n^(logB(A))

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

Roots of Unity: Multiply: (r1, theta1) (r2, theta2)

A

([r1 * r2],[Theta1 + Theta2])

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

Roots of Unity: Given the following equation for Z, what would -Z be. Z = (r, theta)

A

-Z = (t, theta + pi)

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

Roots of Unity: Roots of unity can be solved using the formula Z = (r, theta) What is the nth root of unity: E.g. Z^n = ???? (Assume a unit circle)

A

Z^n = (1, n*theta)

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

Complex Roots of Unity Reference Card

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

What are 5 steps in the FFT algorithm

(in order, high level)

A

FFT(A, w)

1) if w = 1: Return A(1)
2) Express A(w) in the forms Ae + xAo
3) r1 = Call FFT(Ae, w^2) - evaluate Ae at even power roots of unity.
4) r2= Call FFT(Ao, w^2) - evaluate Ao at even power roots of unity.

k = n/2

5) Loop j = 1 to k - 1:

r[j] = r1[j] + w^j * r2[j]

r[j+k] = r1[j] - w^j * r2[j]

Return = r[0…n]

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

What is the process called that takes values from FFT and converts them back into Coefficients?

How is it done?

A

Interpolation

Rerun the FFT using the values and the inverse of the roots of unity.

Coefficients = 1/n FFT(, w^-1)

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

What is the Big O time for the FFT Algorithm?

A

n log n

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

FFT Algorithm Reference Card

A
18
Q

Algorithm Times:

What is time for finding the median via divide and conquer using Big O notation

A

If we had to sort it, it would require O(nlog(n)) however

using the divide and conquer method we can make it linear at O(n)

19
Q

Median in linear time.

When selecting an algorithm to find a good pivot, what does the coefficient a for the master theorem be for the recurrence equation T(an) + O(n) = O(n)

A

The recurrence equation T(n) = T(an) + O(n)

The a must be < 1 to converge to O(n)

We need a pivot that guarantees we eliminate a constant fraction of elements each iteration.

20
Q

Median in linear time

What is the definition of a good pivot (in terms of partition size)?

A

A good pivot is if our pivot point divides the list between

25% and 75% of the list size.

21
Q

Describe the high level steps to perform a FastSelect

Set = A

Number Element to find = k

6 steps

A

1) Break the elements A into n/5 groups of 5 elements.
2) Sort each subgroup (with only 5 elements it’s O(1) & select the median from each sub group
4) Combine the medians from all n/5 groups into a new set A
5) Call Fast Select with the new group, and k/5, this returns a partition value p.
6) Partition A into A

p

6) If K <= A

if K > A

p, k-len(|A

Else return P

22
Q

Median in linear time

What is the recurrence equation for finding the median in O(n) time including the slack time.

A

T(n) = T(3n/4) + T(n/5) + O(n)

The selection of a good pivot is T(3n/4) remember that by selecting a pivot in the mid 50% (between n/4 and 3n/4, our worst partition would have 3n/4 elements.

The T(n/5) is slack time. Remember that for the above equation to equal O(n) the T numbers must add up to be less than 1. So 3n/4 leaves us slack (1/4) and if we can find a good pivot in that T(n/5) + O(n) time, we will still have an O(n) algorithm.

23
Q

Median Reference Card

A
24
Q

Proof that P is a good pivot?

Reference

A

Graphically, groups are broken down into elements of 5

Those groups are sorted so everything above the middle element is less than it, everything below greater.

If we sort those grouped elements, the very middle median is our result. That is at position 1/2 * n/5 or n/10

Looking at that, everything to the left and above it has to be less than or equal to that pivot point. In groups of 5, that means we have 3 elements above the line. giving us 3n/10 in the worst case.

3/10 = 30%, best case is the inverse 7/10 = 70%. We wanted our selection between 25% and 75% to be a good pivot, so this algorithm always gives us a value in the range we need.

25
Q

What is the sum of the nth roots of unity when both even and odd roots are kept in?

A

0

26
Q

What is the product of all the even roots of unity?

A

-1

27
Q

What is the product of all the odd roots of unity?

A

1

28
Q

What is the big-O time for FastMultiplication

What is the big-o time for normal multiplication

A

O(nlog23)

O(n2)

29
Q

What is big-O time for Merge Sort

A

O(n log(n))

30
Q

What is a common equivilant equation for the following:

-(Wnk)

A

-(Wnk+n/2)

31
Q

What is another equivilant formula for

(INVERSE)

(wnk)-1

A

(wnn-k)

or

(wn-k)

32
Q

What is the equivilant of the following:

(Square)

(wnk)2

A

(wn/2k)

Squaring is the same as reducing the number of elements. (This is important for FFT)

33
Q

For an n-1 degree polynomial with size n, what will be the root of unity that we will use.

A

we use the nth root of unity.

34
Q

What does the following formula equal:

(wnk)-1 * (wnk) =

A

1

35
Q

What is the recurrence for a single source shortest path?

A

36
Q

The number of candidates for an optimal solution to a single source shortest path is equal to?

A

The number (1 + the number of verticies going into the end point.)

37
Q

What is the big-O time for the single source shortest path algorithm?

A

O(n3)

  1. Loop one (1 to n) for the sub problem size. How many hops?
  2. Inner loops 2, for each vertex in the verticies
  3. third inner loop is the recurrence to find the min, goes through all edge weights going into a node.
38
Q

Single Shortest Path Base Case?

A

A[0,S] = 0

A[.,.] = +Inf

39
Q

When does the single shortest path algorith stop?

A

When the edge budget n has been exhausted

Or

When the responses stabilize and no more changes are made to the costs in an iteration.

40
Q

What is Eculid’s extended formula for GCD

A

gcd(a,b) = d

d = ax + by

gcd(b, a mod b) = bx + (a mod b)y