CSCE 411 Lecture 5

From Notes
Jump to navigation Jump to search
Lecture Slides

« previous | Wednesday, September 5, 2012 | next »


Example Limit Superior

Therefore

Divide and Conquer

  1. Divide a problem into subproblems
  2. Recursively solve subproblems
  3. Combine solutions to subproblems to get solution to original problem

Example: Merge-sort

  1. Divide the input in half
  2. Recursively sort the two halves (basis is a sequence with 1 key)
  3. Combine two sorted subsequences by merging them

Recurrence Relation

How long does Merge-sort take?

Let be the worst-case time on a sequence of keys.

If , then (constant)

If , then (2 × time of solving each half and then the merge)


Two ways to solve:

  1. Expand several times, guess pattern, and try to prove by induction. (hard!)
  2. Master theorem

Using the master theorem, and . Therefore,

Master Theorem

(See Master Theorem→)


Given a recursive function (recurrence relation) of the form

Let . This represents the number of "leaf operations" in the divide-and-conquer tree

  1. If then
  2. If then
  3. If then


Other D&C Algorithms

  • Mathematics
    • Converting Binary to Decimal
    • Integer Multiplication
    • Matrix Multiplication
    • Matrix Inversion
    • Fast Fourier Transform