Theoretical Algorithm Analysis Flashcards

(15 cards)

1
Q

What are the basic steps for analyzing an algorithm?

A
  1. Identify critical operators
  2. Count operations performed
  3. Express number of operations as function of input size (input = n -> f(n)
  4. Express f(n) using Big-O Notation
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is an Average Case Analysis?

A

Considering all possible cases, making the appropriate assumptions for the likelihood of each case, and average the case operation numbers

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

What is an upper bound?

A

f(n) = O(g(n)), where g(n) is the largest part of f(n)

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

What is the tightest upper bound of:
f(n) = 1000nlogn + 3n^2 + 74n + 1/2n^3

A

f(n) = O(n^3)

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

What is the tightest upper bound of:
f(n) = 45n + n(n-1)/2 + nlogn

A

f(n) = O(n^2)

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

What is Recurrence Relation?

A

The function that will be substituted backwards until the Base Case is reached

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

What is the T(n) of an algorithm?

A

The number of critical operations needed to solve the problem when input is size n

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

What is the SIMPLIFIED T(n) of a problem?

A

The cost of solving one or more reduced size problems + The cost of pre/post processing

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

What is T(n) used for?

A

To find the Big-O of theoretical algorithms by figuring out the cost of the critical operations, since there is no code to analyze

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

What is the General Term and T(n) of this problem, given the RR and BC?

RR: T(n) = 1 + T(n - 1)
BC: T(0) = 0

RR: Recurrence Relation BC: Base Case

A

General Term: k + T(n-k)
T(n) = n = O(n)

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

What is the General Term and T(n) of this problem, given the RR and BC?

RR: T(n) = 2T(n/2) + n - 1
BC: T(1) = 0

RR: Recurrence Relation BC: Base Case

A

General Term: 2^kT(n/2^k) - kn
T(n) = nlog_2(n) = O(n log(n))

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

What is the General Term and T(n) of this problem, given the RR and BC?

RR: T(n) = 1 + T(n/2)
BC: T(1) = 1

RR: Recurrence Relation BC: Base Case

A

General Term: k + T(n/2^k)
T(n) = log_2(n) + 1 = O(log(n))

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

What is the General Term and T(n) of this problem, given the RR and BC?

RR: T(n) = n - 1 + T(n-1)
BC: T(1) = 0

RR: Recurrence Relation BC: Base Case

A

General Term: (n-1) + (n-2) + … + k + T(k)
T(n) = n(n-1)/2 = O(n^2)

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

What is the General Term and T(n) of this problem, given the RR and BC?

RR: T(n) = 2T(n - 1) + 1
BC: T(0) = 0

RR: Recurrence Relation BC: Base Case

A

General Term: 2^kT(n-k) + 2^k-1 + 2^k-2
+ … +2^1 + 2^0
T(n) = 2^n - 1 = O(2^n)

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

What can you do when trying to find the Upper/Lower bounds?

A

You can over estimate during substitution for the upper bound, and under estimate during substitution for the lower bound

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