Intro to Computer Algorithms Lecture 15 Phillip G. Bradford Computer Science University of Alabama
Announcements Advisory Board’s Industrial Talk Series Departmental Colloquium 27-Oct, in 110 East Engineering Featuring Dr. Gary McGraw “Building Secure Software Why the standard approach to security doesn't work”
CS Story Time Prof. Jones’ research group See
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
Outline Transform and conquer Technique Examples
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
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
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!
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
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
Classic Examples: Mode A better solution using transform and conquer Sort first! Transforming the challenge into a simpler one Algorithm on Page 196 Cost?
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?
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