Intro to Computer Algorithms Lecture 11 Phillip G. Bradford Computer Science University of Alabama.

11
Intro to Computer Algorithms Lecture 11 Phillip G. Bradford Computer Science University of Alabama

Transcript of Intro to Computer Algorithms Lecture 11 Phillip G. Bradford Computer Science University of Alabama.

Page 1: Intro to Computer Algorithms Lecture 11 Phillip G. Bradford Computer Science University of Alabama.

Intro to Computer Algorithms Lecture 11

Phillip G. BradfordComputer Science

University of Alabama

Page 2: Intro to Computer Algorithms Lecture 11 Phillip G. Bradford Computer Science University of Alabama.

Announcements

Advisory Board’s Industrial Talk Series http://www.cs.ua.edu/9IndustrialSeries.shtm

Coop Interview Days: Oct 14th and 15th Signup begins on 22nd of September At least 40 firms looking for coop

students!

Page 3: Intro to Computer Algorithms Lecture 11 Phillip G. Bradford Computer Science University of Alabama.

Outline

Go over HW 4 More Divide-and-Conquer &

Analysis Exam Review

Page 4: Intro to Computer Algorithms Lecture 11 Phillip G. Bradford Computer Science University of Alabama.

First Midterm Exam

I expect a good deal of preparation by my class

Thursday 9-October Closed Book & Closed Notes Start with your home works Text book Notes

Page 5: Intro to Computer Algorithms Lecture 11 Phillip G. Bradford Computer Science University of Alabama.

The week of 6-Oct

I will be in Taiwan and Hong Kong doing research

Prof. Borie will give Lectures in my absence!

Page 6: Intro to Computer Algorithms Lecture 11 Phillip G. Bradford Computer Science University of Alabama.

Back to the Closest Pair Problem

N points, then (N choose 2) pairs Compute the distance between

each possible pair and Find the minimum of this list of O(N2)

distances Total cost: O(N2) Can we do better?

Page 7: Intro to Computer Algorithms Lecture 11 Phillip G. Bradford Computer Science University of Alabama.

The Closest Pair Problem

How about divide-and-conquer on the x-coordinate? Then the y-coordinate? What’s wrong with this?

Splitting the set gives a large cost for re-merging

Sort by x-coordinate and recursively by y-coordinate

Page 8: Intro to Computer Algorithms Lecture 11 Phillip G. Bradford Computer Science University of Alabama.

The Closest Pair Problem

d1

d2

d d

Page 9: Intro to Computer Algorithms Lecture 11 Phillip G. Bradford Computer Science University of Alabama.

The Closest Pair Problem

The 6 points principle

P

d

d

d

d

Page 10: Intro to Computer Algorithms Lecture 11 Phillip G. Bradford Computer Science University of Alabama.

The Closest Pair Problem

Cost? O(N log N) per dimension T(N) = 2T(N/2) + cN Master Theorem: T(N) = O(N log

N).

Page 11: Intro to Computer Algorithms Lecture 11 Phillip G. Bradford Computer Science University of Alabama.

Exam Review Solving Recurrences

Unwinding: Formality expected by induction

Master Theorem: give a, b and d. Designing & Analyzing Exhaustive

Sear or Brute Force Algorithms Designing & Analyzing Divide and

Conquer Algorithms