Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Intro to Computer Algorithms Lecture 15 Phillip G. Bradford Computer Science University of Alabama."— Presentation transcript:

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

2 Announcements Advisory Board’s Industrial Talk Series http://www.cs.ua.edu/9IndustrialSeries.shtm Departmental Colloquium 27-Oct, in 110 East Engineering Featuring Dr. Gary McGraw “Building Secure Software Why the standard approach to security doesn't work”

3 CS Story Time Prof. Jones’ research group See http://cs.ua.edu/StoryHourSlide.pdfhttp://cs.ua.edu/StoryHourSlide.pdf

4 Association of Computing Machinery “The First Society in Computing” Meeting & Information Session: Tuesday, October 21 Time and Place: EE 119 at 5:00 p.m. Join us on Tuesday for FREE FOOD and good information: Guest Speaker: Beth Green, Wal-Mart ISD Recruiting Who & What is Wal-Mart hiring? For more info, visit www.studentacm.org

5 Outline Transform and conquer Technique Examples

6 Transform and Conquer Start with a problem instance PI Change or transform PI into SI Simpler Instance So that solving SI solves PI Solve the simpler SI

7 Transformation in more detail Instance Simplification Make simpler or more convenient Representation Change Different representation of the same problem Problem Reduction Instance of a problem that has already been solved

8 Classic Examples: Element Uniqueness Presorting Once a list is sorted, then it is easy to get some forms of information from it Element Uniqueness Determine if any two elements in a list are the same How? Sort and then check neighbors Cost? O(n log n) counting the sort!

9 Classic Examples: Mode Computing the Mode of a list of elements What is the mode? Most common occurring element How? Brute force method For each element count how often it occurs Track the largest occurring element so far

10 Classic Examples: Mode The O(n 2 ) solution mode_freq  0 mode_value  0 run_value  0 run_length  0 The algorithm at the board

11 Classic Examples: Mode A better solution using transform and conquer Sort first! Transforming the challenge into a simpler one Algorithm on Page 196 Cost?

12 Classic Examples: Searching vs. Sorting Given the cost of comparison based sorting is O(n log n) The cost of searching a sorted list is O(log n) How many searches through a length n list do we have to do to justify a sort?

13 Gaussian Elimination Classic Transform and conquer Transformation uses row operations Exchange two rows Replace an equation with an non-zero multiple Replace an equation with the sum or difference of itself and another equation Examples at the board


Download ppt "Intro to Computer Algorithms Lecture 15 Phillip G. Bradford Computer Science University of Alabama."

Similar presentations


Ads by Google