Intro to Computer Algorithms Lecture 15 Phillip G













- Slides: 13
Intro to Computer Algorithms Lecture 15 Phillip G. Bradford Computer Science University of Alabama
Announcements n Advisory Board’s Industrial Talk Series n n http: //www. cs. ua. edu/9 Industrial. Series. shtm Departmental Colloquium n n n 27 -Oct, in 110 East Engineering Featuring Dr. Gary Mc. Graw “Building Secure Software Why the standard approach to security doesn't work”
CS Story Time n n Prof. Jones’ research group See http: //cs. ua. edu/Story. Hour. Slide. pdf
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
Outline n Transform and conquer n n Technique Examples
Transform and Conquer n n Start with a problem instance PI Change or transform PI into SI n n n Simpler Instance So that solving SI solves PI Solve the simpler SI
Transformation in more detail n Instance Simplification n n Representation Change n n Make simpler or more convenient Different representation of the same problem Problem Reduction n Instance of a problem that has already been solved
Classic Examples: Element Uniqueness n Presorting n n Once a list is sorted, then it is easy to get some forms of information from it Element Uniqueness n n Determine if any two elements in a list are the same How? n n Sort and then check neighbors Cost? n O(n log n) counting the sort!
Classic Examples: Mode n Computing the Mode of a list of elements n What is the mode? n n Most common occurring element How? n Brute force method n For each element count how often it occurs n Track the largest occurring element so far
Classic Examples: Mode n The O(n 2) solution n n mode_freq 0 mode_value 0 run_length 0 The algorithm at the board
Classic Examples: Mode n n A better solution using transform and conquer Sort first! n n n Transforming the challenge into a simpler one Algorithm on Page 196 Cost?
Classic Examples: Searching vs. Sorting n n n 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 n Classic Transform and conquer n Transformation uses row operations n n 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