Download Intro to Computer Algorithms Lecture 6

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Computational electromagnetics wikipedia , lookup

Artificial intelligence wikipedia , lookup

Algorithm wikipedia , lookup

Mathematical optimization wikipedia , lookup

Pattern recognition wikipedia , lookup

Lateral computing wikipedia , lookup

Coase theorem wikipedia , lookup

Binary search algorithm wikipedia , lookup

Computational complexity theory wikipedia , lookup

Knapsack problem wikipedia , lookup

String (computer science) wikipedia , lookup

Multiple-criteria decision analysis wikipedia , lookup

Theoretical computer science wikipedia , lookup

Genetic algorithm wikipedia , lookup

Transcript
Intro to Computer Algorithms
Lecture 6
Phillip G. Bradford
Computer Science
University of Alabama
Announcements


Colloquia on Monday 22-Sept
David M. Mount presents:


“Approximation Algorithms for
Clustering”
At 11:00 in 108 Houser
Lecture Outline





Homework Assignment
Review last lecture
More on Recurrences
Exhaustive Search
Divide and Conquer
Reading


Up through Chapter 3
Start Chapter 4.
Exhaustive Search

Brute-Force String Matching





Elements in string: n
Elements in search string: m
Closest Point Problems
Traveling Salesperson
Knapsack Problem
More Recurrence Examples

T(n) = 2T(n/2) + 1


Solution?
How about

T(n) = 2T(n/2) + n

Assume n is a power of 2.
Divide and Conquer



Divide instance in to parts
Solve problem on the parts
Combine the solutions
The Master Theorem


T(n) = aT(n/b) + f(n)
M. Theorem. Suppose f(n) is Q(nd) and
d > 0. Then T(n) is



Q(nd)
if a < bd
Q(nd log n) if a = bd
Q(nlogba)
if a > bd
Examples

Recall, T(n) = 2T(n/2) + 1

Here, f(n) = 1 and a = b = 2 and d = 0.


So, a > bd
Giving: T(n) is Q(nlogba) = Q(n)