MA/CSSE 473 Day 13 Divide and Conquer Closest Points Convex Hull Answer Quiz Question 1.

Slides:



Advertisements
Similar presentations
2/9/06CS 3343 Analysis of Algorithms1 Convex Hull  Given a set of pins on a pinboard  And a rubber band around them  How does the rubber band look when.
Advertisements

Lecture 3: Parallel Algorithm Design
Divide-and-conquer: closest pair (Chap.33) Given a set of points, find the closest pair (measured in Euclidean distance) Brute-force method: O(n 2 ). Divide-and-conquer.
Lecture 4 Divide and Conquer for Nearest Neighbor Problem
Divide-and-Conquer The most-well known algorithm design strategy:
The Divide-and-Conquer Strategy
A. Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 5 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
1 Divide-and-Conquer The most-well known algorithm design strategy: 1. Divide instance of problem into two or more smaller instances 2. Solve smaller instances.
Divide and Conquer The most well known algorithm design strategy: 1. Divide instance of problem into two or more smaller instances 2. Solve smaller instances.
CS4413 Divide-and-Conquer
Reminder: Closest-Pair Problem Given a collection P of n points in  × , obtain the two points p1 and p2 such that their distance is less or equal that.
Chapter 4: Divide and Conquer Master Theorem, Mergesort, Quicksort, Binary Search, Binary Trees The Design and Analysis of Algorithms.
Theory of Algorithms: Divide and Conquer
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Divide and Conquer.
Introduction to Algorithms Rabie A. Ramadan rabieramadan.org 6 Ack : Carola Wenk nad Dr. Thomas Ottmann tutorials.
Divide and Conquer. Recall Complexity Analysis – Comparison of algorithm – Big O Simplification From source code – Recursive.
8/29/06CS 6463: AT Computational Geometry1 CS 6463: AT Computational Geometry Spring 2006 Convex Hulls Carola Wenk.
Chapter 4 Divide-and-Conquer Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Nattee Niparnan. Recall  Complexity Analysis  Comparison of Two Algos  Big O  Simplification  From source code  Recursive.
Lecture 8 Jianjun Hu Department of Computer Science and Engineering University of South Carolina CSCE350 Algorithms and Data Structure.
CS Section 600 CS Section 002 Dr. Angela Guercio Spring 2010.
Chapter 4 Divide-and-Conquer Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Chapter 4: Divide and Conquer The Design and Analysis of Algorithms.
Prune-and-search Strategy
CSE 421 Algorithms Richard Anderson Lecture 12 Recurrences.
5 - 1 § 5 The Divide-and-Conquer Strategy e.g. find the maximum of a set S of n numbers.
Design and Analysis of Algorithms - Chapter 41 Divide and Conquer The most well known algorithm design strategy: 1. Divide instance of problem into two.
Divide and Conquer The most well known algorithm design strategy: 1. Divide instance of problem into two or more smaller instances 2. Solve smaller instances.
Design and Analysis of Algorithms - Chapter 41 Divide and Conquer The most well known algorithm design strategy: 1. Divide instance of problem into two.
MA/CSSE 473 Day 03 Asymptotics A Closer Look at Arithmetic With another student, try to write a precise, formal definition of “t(n) is in O(g(n))”
Convex Hull. What is the Convex Hull? Imagine a set of points on a board with a nail hammered into each point. Now stretch a rubber band over all the.
MA/CSSE 473 Day 17 Divide-and-conquer Convex Hull Strassen's Algorithm: Matrix Multiplication.
MA/CSSE 473 Day 02 Some Numeric Algorithms and their Analysis.
Intro to Computer Algorithms Lecture 11 Phillip G. Bradford Computer Science University of Alabama.
Theory of Algorithms: Divide and Conquer James Gain and Edwin Blake {jgain | Department of Computer Science University of Cape Town.
A. Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 5 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
Nattee Niparnan. Recall  Complexity Analysis  Comparison of Two Algos  Big O  Simplification  From source code  Recursive.
© The McGraw-Hill Companies, Inc., Chapter 6 Prune-and-Search Strategy.
The Selection Problem. 2 Median and Order Statistics In this section, we will study algorithms for finding the i th smallest element in a set of n elements.
1 Prune-and-Search Method 2012/10/30. A simple example: Binary search sorted sequence : (search 9) step 1  step 2  step 3  Binary search.
Divide and Conquer Applications Sanghyun Park Fall 2002 CSE, POSTECH.
MA/CSSE 473 Day 02 Some Numeric Algorithms and their Analysis.
Divide-and-Conquer The most-well known algorithm design strategy: 1. Divide instance of problem into two or more smaller instances 2.Solve smaller instances.
Lecture 5 Today, how to solve recurrences We learned “guess and proved by induction” We also learned “substitution” method Today, we learn the “master.
Sorting Fundamental Data Structures and Algorithms Aleks Nanevski February 17, 2004.
MA/CSSE 473 Day 12 Amortization (growable Array) Knuth interview Brute Force Examples.
MA/CSSE 473 Day 14 Strassen's Algorithm: Matrix Multiplication Decrease and Conquer DFS.
Subject Name: Design and Analysis of Algorithm Subject Code: 10CS43
Chapter 4 Divide-and-Conquer
MA/CSSE 473 Day 17 Divide-and-conquer Convex Hull
MA/CSSE 473 Day 16 Answers to your questions Divide and Conquer
MA/CSSE 473 Day 02 Some Numeric Algorithms and their Analysis
Divide-and-Conquer The most-well known algorithm design strategy:
Chapter 4 Divide-and-Conquer
CSCE350 Algorithms and Data Structure
Divide-and-Conquer The most-well known algorithm design strategy:
CSCE 411 Design and Analysis of Algorithms
Divide-and-Conquer The most-well known algorithm design strategy:
Richard Anderson Lecture 13 Divide and Conquer
Richard Anderson Lecture 11 Minimum Spanning Trees
Divide-and-Conquer The most-well known algorithm design strategy:
Chapter 4 Divide-and-Conquer
Divide-and-Conquer The most-well known algorithm design strategy:
CSC 380: Design and Analysis of Algorithms
CSC 380: Design and Analysis of Algorithms
Introduction to Algorithms
CSC 380: Design and Analysis of Algorithms
Given a list of n  8 integers, what is the runtime bound on the optimal algorithm that sorts the first eight? O(1) O(log n) O(n) O(n log n) O(n2)
Divide and Conquer Merge sort and quick sort Binary search
Presentation transcript:

MA/CSSE 473 Day 13 Divide and Conquer Closest Points Convex Hull Answer Quiz Question 1

MA/CSSE 473 Day 13 HW 6 is due today Monday Student Questions Divide and Conquer Closest Points (If time) Convex Hull Q1

DIVIDE AND CONQUER ALGORITHMS Today: Closest Points, Convex Hull

Divide-and-conquer algorithms Definition Examples seen prior to this course or so far in this course Q1

Closest Points problem Given a set, S, of N points in the xy-plane, find the minimum distance between two points in S. Running time for brute force algorithm? Next we examine a divide-and-conquer approach.

Closest Points "divide" phase S is a set of N points in the xy-plane For simplicity, we assume N = 2 k for some k. Sort the points by x-coordinate –If two points have the same x-coordinate, order them by y-coordinate –If we use merge sort, the worst case is Ѳ(N log N) Let c be the median x-value of the points Let S 1 be {(x, y): x ≤ c}, and S 2 be {(x, y): x ≥ c} –adjust so we get exactly N/2 points in each subset Q2

Closest Points "conquer" phase Assume that the points of S are sorted by x- coordinate, then by y-coordinate if x's are equal Let d 1 be the minimum distance between two points in S 1 (the set of "left half" points) Let d 2 be the minimum distance between two points in S 2 (the set of "right half" points) Let d = min(d 1, d 2 ). Is d the minimum distance for S? What else do we have to consider? Suppose we needed to compare every point in S 1 to every point in S 2. What would the running time be? How can we avoid doing so many comparisons? Q3 Q4

Reference: The Master Theorem The Master Theorem for Divide and Conquer recurrence relations: Consider the recurrence T(n) = aT(n/b) +f(n), T(1)=c, where f(n) = Ѳ(n k ) and k≥0, The solution is –Ѳ(n k )if a < b k –Ѳ(n k log n)if a = b k –Ѳ(n log b a )if a > b k For details, see Levitin pages or Weiss section Grimaldi's Theorem 10.1 is a special case of the Master Theorem. We will use this theorem often. You should review its proof soon (Weiss's proof is a bit easier than Levitin's).

After recursive calls on S 1 and S 2 d = min(d 1, d 2 ). Q5-6

Convex Hull Problem Again, sort by x-coordinate, with tie going to larger y-coordinate. Q7-9

Recursive calculation of Upper Hull

Simplifying the Calculations We can simplify two things at once: Finding the distance of P from line P 1 P 2, and Determining whether P is "to the left" of P 1 P 2 –The area of the triangle through P 1 =(x 1,y 1 ), P 2 =(x 2,y 2 ), and P 3 =(x 3,y e ) is ½ of the absolute value of the determinant For a proof of this property, see How do we use this to calculate distance from P to the line? –The sign of the determinant is positive if the order of the three points is clockwise, and negative if it is counter- clockwise Clockwise means that P 3 is "to the left" of directed line segment P 1 P 2 Speeding up the calculation Q10

Efficiency of quickhull algorithm What arrangements of points give us worst case behavior? Average case is much better. Why? Q11-12