Data Structures and Algorithms (AT70. 02) Comp. Sc. and Inf. Mgmt

Slides:



Advertisements
Similar presentations
Lecture 3: Parallel Algorithm Design
Advertisements

Data Structures and Algorithms (AT70.02) Comp. Sc. and Inf. Mgmt. Asian Institute of Technology Instructor: Dr. Sumanta Guha Slide Sources: CLRS “Intro.
Data Structures and Algorithms (AT70.02) Comp. Sc. and Inf. Mgmt. Asian Institute of Technology Instructor: Dr. Sumanta Guha Slide Sources: CLRS “Intro.
Data Structures and Algorithms (AT70.02) Comp. Sc. and Inf. Mgmt. Asian Institute of Technology Instructor: Dr. Sumanta Guha Slide Sources: CLRS “Intro.
Copyright © 2007 Pearson Addison-Wesley. All rights reserved. Problem Reduction Dr. M. Sakalli Marmara Unv, Levitin ’ s notes.
Lectures on Recursive Algorithms1 COMP 523: Advanced Algorithmic Techniques Lecturer: Dariusz Kowalski.
Convex Hulls in Two Dimensions Definitions Basic algorithms Gift Wrapping (algorithm of Jarvis ) Graham scan Divide and conquer Convex Hull for line intersections.
The Divide-and-Conquer Strategy
Data Structures and Algorithms (AT70.02) Comp. Sc. and Inf. Mgmt. Asian Institute of Technology Instructor: Dr. Sumanta Guha Slide Sources: CLRS “Intro.
Convex Hulls May Shmuel Wimer Bar Ilan Univ., Eng. Faculty Technion, EE Faculty.
Computational Geometry
8/29/06CS 6463: AT Computational Geometry1 CS 6463: AT Computational Geometry Spring 2006 Convex Hulls Carola Wenk.
Advanced Algorithm Design and Analysis (Lecture 10) SW5 fall 2004 Simonas Šaltenis E1-215b
1 Today’s Material Computational Geometry Problems –Closest Pair Problem –Convex Hull Jarvis’s March, Graham’s scan –Farthest Point Problem.
Chapter 4: Divide and Conquer The Design and Analysis of Algorithms.
5 - 1 § 5 The Divide-and-Conquer Strategy e.g. find the maximum of a set S of n numbers.
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.
Computational Geometry (35/33) Line Segments and cross-product Segment intersection and Sweep Line Convex Hull and Graham’s Scan, Jarvis’s march Divide-and-Conquer.
1 Closest Pair of Points (from “Algorithm Design” by J.Kleinberg and E.Tardos) Closest pair. Given n points in the plane, find a pair with smallest Euclidean.
Data Structures and Algorithms (AT70.02) Comp. Sc. and Inf. Mgmt. Asian Institute of Technology Instructor: Prof. Sumanta Guha Slide Sources: CLRS “Intro.
Data Structures and Algorithms (AT70.02) Comp. Sc. and Inf. Mgmt. Asian Institute of Technology Instructor: Prof. Sumanta Guha Slide Sources: CLRS “Intro.
Data Structures and Algorithms (AT70.02) Comp. Sc. and Inf. Mgmt. Asian Institute of Technology Instructor: Prof. Sumanta Guha Slide Sources: CLRS “Intro.
Week 4 Functions and Graphs. Objectives At the end of this session, you will be able to: Define and compute slope of a line. Write the point-slope equation.
Data Structures and Algorithms (AT70.02) Comp. Sc. and Inf. Mgmt. Asian Institute of Technology Instructor: Prof. Sumanta Guha Slide Sources: CLRS “Intro.
Copyright © Cengage Learning. All rights reserved. 6.3 Vectors in the Plane.
SOLVING SYSTEMS USING ELIMINATION 6-3. Solve the linear system using elimination. 5x – 6y = -32 3x + 6y = 48 (2, 7)
Convex Hull 2012/10/23. Convex vs. Concave A polygon P is convex if for every pair of points x and y in P, the line xy is also in P; otherwise, it is.
Data Structures and Algorithms (AT70.02) Comp. Sc. and Inf. Mgmt. Asian Institute of Technology Instructor: Prof. Sumanta Guha Slide Sources: CLRS “Intro.
Data Structures and Algorithms (AT70.02) Comp. Sc. and Inf. Mgmt. Asian Institute of Technology Instructor: Prof. Sumanta Guha Slide Sources: CLRS “Intro.
Data Structures and Algorithms (AT70.02) Comp. Sc. and Inf. Mgmt. Asian Institute of Technology Instructor: Prof. Sumanta Guha Slide Sources: CLRS “Intro.
Data Structures and Algorithms (AT70. 02) Comp. Sc. and Inf. Mgmt
Advanced Algorithms Analysis and Design
Chapter 2. Divide-and-conquer Algorithms
Searching and Sorting Algorithms
translations, rotations, and reflections
Data Structures and Algorithms (AT70. 02) Comp. Sc. and Inf. Mgmt
Graphing Linear Equations
3.2 Solving Systems by Elimination
Data Structures and Algorithms (AT70. 02) Comp. Sc. and Inf. Mgmt
Data Structures and Algorithms (AT70. 02) Comp. Sc. and Inf. Mgmt
MA/CSSE 473 Day 16 Answers to your questions Divide and Conquer
Convex Hull R.L. Graham’s Algorithm Computer Graphics.
Convex Hull.
Data Structures and Algorithms (AT70. 02) Comp. Sc. and Inf. Mgmt
Data Structures and Algorithms (AT70. 02) Comp. Sc. and Inf. Mgmt
CSCE350 Algorithms and Data Structure
Algorithm design techniques Dr. M. Gavrilova
Data Structures and Algorithms (AT70. 02) Comp. Sc. and Inf. Mgmt
Computational Geometry (35/33)
Data Structures and Algorithms (AT70. 02) Comp. Sc. and Inf. Mgmt
Geometry.
Chapter 5 Divide and Conquer
Convex Sets & Concave Sets
Data Structures and Algorithms (AT70. 02) Comp. Sc. and Inf. Mgmt
Computational Geometry for the Tablet PC
Copyright © Cengage Learning. All rights reserved.
Data Structures and Algorithms (AT70. 02) Comp. Sc. and Inf. Mgmt
Data Structures and Algorithms (AT70. 02) Comp. Sc. and Inf. Mgmt
CHAPTER 33 Computational Geometry
Data Structures and Algorithms (AT70. 02) Comp. Sc. and Inf. Mgmt
Data Structures and Algorithms (AT70. 02) Comp. Sc. and Inf. Mgmt
Divide-and-Conquer The most-well known algorithm design strategy:
CMPS 3120: Computational Geometry Spring 2013
Data Structures and Algorithms (AT70. 02) Comp. Sc. and Inf. Mgmt
CSCI 256 Data Structures and Algorithm Analysis Lecture 12
Computational Geometry Algorithms
Geometry.
Data Structures and Algorithms (AT70. 02) Comp. Sc. and Inf. Mgmt
Algorithms and Data Structures Lecture XIV
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)
Presentation transcript:

Data Structures and Algorithms (AT70. 02) Comp. Sc. and Inf. Mgmt Data Structures and Algorithms (AT70.02) Comp. Sc. and Inf. Mgmt. Asian Institute of Technology Instructor: Prof. Sumanta Guha Slide Sources: CLRS “Intro. To Algorithms” book website (copyright McGraw Hill) adapted and supplemented

CLRS “Intro. To Algorithms” Ch. 33: Computational Geometry

If p1 = (x1, y1) and p2 = (x2, y2) then p1  p2 = x1 x2 = x1y2 – x2y1* y1 y2 If p1  p2 > 0, then p1 is clockwise from p2 (turning around the origin); if p1  p2 < 0, then p1 is counterclockwise from p2; If p1  p2 = 0, then p1 and p2 are collinear (pointing in either same or opposite directions) * The cross product is actually a 3D vector whose magnitude is |x1y2 – x2y1|. Here we simplify for 2D.

If DIRECTION(pi, pj, pk) > 0, then pj – pi is a left turn from pk – pi around pi < 0, then pj – pi is a right turn from pk – pi around pi = 0, then pj – pi and pk – pi are collinear

How?!

Eliminate the polar co-ordinate sort part of Graham’s scan by modifying it to scan the vertices sorted from left to right. Otherwise, the underlying principle, data structures, etc. remain the same. Comment : This modification of Graham’s scan was made by Andrew (1979) and is often called the Monotone Chain algorithm.

Jarvis’s march is output-sensitive!

Closest Pair by Divide-and-Conquer Following slides are copied from Dariusz Kowalski (www.csc.liv.ac.uk/~darek/COMP523/lecture5.ppt)

Lecture 5: Divide and Conquer, cont. (Dariusz Kowalski) Solution Preprocessing: Sort points according to the first coordinate (obtain horizontal list H) and according the second coordinate (obtain vertical list V) Main Algorithm: Partition list H input into halves in linear time (draw vertical line L containing medium point) Solve the problem for each half of the input separately, obtaining two pairs of closest points; let  be the smallest distance from the obtained ones Find if there is a pair which has distance smaller than  - if yes then find the smallest distance pair Lecture 5: Divide and Conquer, cont. (Dariusz Kowalski)

Lecture 5: Divide and Conquer, cont. (Dariusz Kowalski) Main difficulty Find if there is a pair which has distance smaller than  - if yes then find the smallest distance pair How to do it in linear time?    Lecture 5: Divide and Conquer, cont. (Dariusz Kowalski)

Closest pair in the strip 1. Find a sublist P of V containing all points with a distance at most  from the line L - in linear time 2. For each element in P check its distance to the next 8 elements and remember the closest pair ever found    Lecture 5: Divide and Conquer, cont. (Dariusz Kowalski) L

Why to check only 8 points ahead? 1. Partition the strip into squares of length /2 as shown in the picture. 2. Each square contains at most 1 point - by definition of . 3. If there are at least 2 squares between points then they can not be the closest points. 4. There are at most 8 squares to check.  /2 /2 /2 /2 /2 /2 Lecture 5: Divide and Conquer, cont. (Dariusz Kowalski) L

Problems Ex. 33.3-2 Ex. 33.3-4 Ex. 33.3-5 Ex. 33.3-6 Ex. 33.4-3