Divide and Conquer Paradigm Flashcards

1
Q

Describe the three steps that the divide and conquer paradigm divides recursion into

A
  • Divide* the problems into sub problems of the same problem - D(n)
  • Conquer* each subproblem. Solve either recursively or not - aT(n)
  • Combine* the solutions into an overall solution - C(n)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is recurrence

A

An equation or inequality that describes a function in terms of ites value on smaller functions

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

what is the recurrence equation of merge sort

A

c if n = 1

2T(n/2) + cn n>1

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

what is the recurrence equation of factorial

A

c if n = 1

T(n-1) + c n>1

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

what is the recurrence equation of binary search

A

c if n = 1

T(n/2) + c n>1

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

describe the substitution method to solve recurrences

A

make a good guess.

  1. guess the form of the answer
  2. use induction to find constants
  3. show the solution works.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

describe the iteration method to solve recurrences

A
  1. expand the recurrence
  2. work out the algebra to express as a sum
  3. evaluate the sum
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

describe the master method to solve recurrences

A

T(n) = a T(n/b) + f(n)

  1. find a b and f(n)
  2. calculate n^(log_b a)
  3. how does f(n) relate to the above
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

give the three different cases in the master method

A
O(n^log_b a)                   if f(n) = O(n^(log_b a - constant)) 
O(n^(log_b a) log n)        if f(n) = O(n^log_b a)
O(f(n))                               if f(n) = O(n^(log_b a) + constant))
                                         and af(n/b) <= cf(n)   for large n
How well did you know this?
1
Not at all
2
3
4
5
Perfectly