Algorithm design techniques Dr. M. Gavrilova

Slides:



Advertisements
Similar presentations
Computational Geometry
Advertisements

Advanced Topics in Algorithms and Data Structures Lecture 7.2, page 1 Merging two upper hulls Suppose, UH ( S 2 ) has s points given in an array according.
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.
Lecture 3: Parallel Algorithm Design
1/13/15CMPS 3130/6130: Computational Geometry1 CMPS 3130/6130: Computational Geometry Spring 2015 Convex Hulls Carola Wenk.
Brute-Force Triangulation
Advanced Algorithms Piyush Kumar (Lecture 12: Parallel Algorithms) Welcome to COT5405 Courtesy Baker 05.
Computing Convex Hulls CLRS 33.3
Convex Hull obstacle start end Convex Hull Convex Hull
C o m p u t i n g C O N V E X H U L L S by Kok Lim Low 10 Nov 1998 COMP Presentation.
UNC Chapel Hill M. C. Lin Polygon Triangulation Chapter 3 of the Textbook Driving Applications –Guarding an Art Gallery –3D Morphing.
1 Voronoi Diagrams. 2 Voronoi Diagram Input: A set of points locations (sites) in the plane.Input: A set of points locations (sites) in the plane. Output:
The Divide-and-Conquer Strategy
Convex Hulls in Two Dimensions Definitions Basic algorithms Gift Wrapping (algorithm of Jarvis ) Graham scan Divide and conquer Convex Hull for line intersections.
CS4413 Divide-and-Conquer
Introduction to Algorithms Rabie A. Ramadan rabieramadan.org 6 Ack : Carola Wenk nad Dr. Thomas Ottmann tutorials.
By Groysman Maxim. Let S be a set of sites in the plane. Each point in the plane is influenced by each point of S. We would like to decompose the plane.
Advanced Topics in Algorithms and Data Structures Lecture 7.1, page 1 An overview of lecture 7 An optimal parallel algorithm for the 2D convex hull problem,
1 Convex Hull in Two Dimensions Jyun-Ming Chen Refs: deBerg et al. (Chap. 1) O’Rourke (Chap. 3)
Computational Geometry
8/29/06CS 6463: AT Computational Geometry1 CS 6463: AT Computational Geometry Spring 2006 Convex Hulls Carola Wenk.
What does that mean? To get the taste we will just look only at some sample problems... [Adapted from S.Suri]
9/5/06CS 6463: AT Computational Geometry1 CS 6463: AT Computational Geometry Fall 2006 Plane Sweep Algorithms and Segment Intersection Carola Wenk.
Intersections. Intersection Problem 3 Intersection Detection: Given two geometric objects, do they intersect? Intersection detection (test) is frequently.
Computational Geometry Piyush Kumar (Lecture 3: Convexity and Convex hulls) Welcome to CIS5930.
Query Processing in Databases Dr. M. Gavrilova.  Introduction  I/O algorithms for large databases  Complex geometric operations in graphical querying.
Robert Pless, CS 546: Computational Geometry Lecture #3 Last Time: Convex Hulls Today: Plane Sweep Algorithms, Segment Intersection, + (Element Uniqueness,
Computational Geometry -- Voronoi Diagram
17. Computational Geometry Chapter 7 Voronoi Diagrams.
1 Lecture 8: Voronoi Diagram Computational Geometry Prof. Dr. Th. Ottmann Voronoi Diagrams Definition Characteristics Size and Storage Construction Use.
Lecture 12 : Special Case of Hidden-Line-Elimination Computational Geometry Prof. Dr. Th. Ottmann 1 Special Cases of the Hidden Line Elimination Problem.
Chapter 4: Divide and Conquer The Design and Analysis of Algorithms.
Computational Geometry Overview from Cormen, et al. Chapter 33
5 - 1 § 5 The Divide-and-Conquer Strategy e.g. find the maximum of a set S of n numbers.
Lecture 6 Divide and Conquer for Nearest Neighbor Problem Shang-Hua Teng.
Design and Analysis of Algorithms - Chapter 41 Divide and Conquer The most well known algorithm design strategy: 1. Divide instance of problem into two.
Design and Analysis of Algorithms - Chapter 41 Divide and Conquer The most well known algorithm design strategy: 1. Divide instance of problem into two.
Brute-Force Triangulation
1 Geometric Intersection Determining if there are intersections between graphical objects Finding all intersecting pairs Brute Force Algorithm Plane Sweep.
UNC Chapel Hill M. C. Lin Point Location Reading: Chapter 6 of the Textbook Driving Applications –Knowing Where You Are in GIS Related Applications –Triangulation.
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.
UNC Chapel Hill M. C. Lin Linear Programming Reading: Chapter 4 of the Textbook Driving Applications –Casting/Metal Molding –Collision Detection Randomized.
UNC Chapel Hill M. C. Lin Line Segment Intersection Chapter 2 of the Textbook Driving Applications –Map overlap problems –3D Polyhedral Morphing.
Line Arrangement Chapter 6. Line Arrangement Problem: Given a set L of n lines in the plane, compute their arrangement which is a planar subdivision.
5 -1 Chapter 5 The Divide-and-Conquer Strategy A simple example finding the maximum of a set S of n numbers.
C o m p u t i n g C O N V E X H U L L S. Presentation Outline 2D Convex Hulls –Definitions and Properties –Approaches: Brute Force Gift Wrapping QuickHull.
Convex Hull. University of Manchester biologists used lasers to measure the minimum amount of skin required to wrap around the skeletons of modern-day.
Lecture 5 Today, how to solve recurrences We learned “guess and proved by induction” We also learned “substitution” method Today, we learn the “master.
Common Intersection of Half-Planes in R 2 2 PROBLEM (Common Intersection of half- planes in R 2 ) Given n half-planes H 1, H 2,..., H n in R 2 compute.
Lecture 3: Parallel Algorithm Design
MA/CSSE 473 Day 16 Answers to your questions Divide and Conquer
CMPS 3130/6130 Computational Geometry Spring 2017
Convex Hull.
Query Processing in Databases Dr. M. Gavrilova
CSCE350 Algorithms and Data Structure
CMPS 3130/6130 Computational Geometry Spring 2017
Computational Geometry Capter:1-2.1
I. The Problem of Molding
Convex Hull 1/1/ :28 AM Convex Hull obstacle start end.
CHAPTER 33 Computational Geometry
CMPS 3130/6130: Computational Geometry Spring 2017
Divide-and-Conquer The most-well known algorithm design strategy:
Computational Geometry
CMPS 3120: Computational Geometry Spring 2013
CSC 380: Design and Analysis of Algorithms
CSC 380: Design and Analysis of Algorithms
Introduction to 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)
Major Design Strategies
Algorithm Course Algorithms Lecture 3 Sorting Algorithm-1
Presentation transcript:

Algorithm design techniques Dr. M. Gavrilova CPSC 695 Algorithm design techniques Dr. M. Gavrilova

Algorithmic Strategies Incremental Divide-and-conquer Sweep-line/plane Dimension reduction Geometric decomposition

Common Algorithm Techniques Problem A – you know a lower bound Problem B – it is unknown. If we transform A to B by a transformation step that costs less than solving A, then B has the same lower bound as A

Convex Hull problem Convex Hull → Sorting Sorting is Ω(n log n) Let {x1,x2,…,xn} be a set of numbers (any order) Compute in linear time set of points O(xi,xi2) Build the convex hull of these points By scanning points from left to right obtain sorted array. Convex hull is Ω(n log n) 1 2 3 4 16 9 4 1

Incremental – Convex Hull Let S={p1,p2,…,pn} denote the set of points of CH. First, construct a triangle {p1,p2, p3} Add point pi to CHi-1 (existing) Two cases are possible: pi  CHi-1 – detected in linear time by scanning the points of CHi-1 in clockwise order, pi is always on the right side pi  CHi-1 – add pi to CH in linear time, by scanning points of CHi-1, finding 2 tangential lines from pi to CH. Analysis: O(n2)

Convex Hull – optimization Algorithm can be improved to O(n lg n) by presorting the input according to abscissas of points. Every time a point pi is added: No need to check CHi-1, it is always outside To find the upper tangent, scan the upper chain, removing points that we scanned Lower tangent – same Linear time to construct CH + sorting O(n lg n)

Convex Hull – optimization Algorithm can be improved using the property that the list of points is sorted. If line through Pi intersects CH, the vertex is discarded. Each vertex is discarded only once. Pi Pi-1

Divide-and-conquer The half-plane intersection example: result – convex polygon Recursive: Top-down: subdivision to a smaller problem Bottom-up: recursively merging the solution Similar to merge-sort, quick-sort

Divide-and-conquer Create binary tree of half-planes Intersect each half-plane, starting from the leaves, with rectangle R, which contains the resulting polygon (by assumption)  obtain convex polygons Compute intersection of convex polygons, bottom up on the tree

Divide-and-conquer

Divide-and-conquer complexity Convex polygon intersection is O(n) T(n) = 2 T(n/2) + cn i is # of steps  T(n) = 2i T(n/2i)+cni T(n) = 2lg n T(n/2lg n) + c n lg n Assume T(n/2lg n) is O(1), when the size of the problem is small T(n) = O(n lg n)

Sweep-line (plane-sweep) Decompose the input into vertical strips Vertical line (sweep-line) allows to compute/maintain some information Sweep-line goes through a number of events Event list is usually represented by the queue The state of the sweep-line is also maintained.

Sweep-line example Given a set S of rectangles with sides parallel to the axes, report all their pair-wise intersections O(n2) – for each rectangle, test intersections with others This is worst-case optimal, because there can be that many intersections. However, let’s try to design an output-sensitive algorithm.

Sweep-line example Observations: Sweep-line undergoes changes in its status when it reaches left/right side of a rectangle (along X coordinate) If X projections intersect – does not mean that rectangles intersect. When left endpoint reached – add rectangle. When the sweep-line intersects the rectangles, Y projections of rectangles should be checked for intersection. If they too intersect, then rectangles intersect. When right endpoint is added – remove rectangle. All events can be scheduled in advance!

Sweep line – complexity Initial sorting of interval endpoints O(n lg n) # of events in the queue is 2n Time to process one event – check for Y intersections is O(1) If the total # of intersections is k, then the total complexity is O(n lg n + k)

Dimension reduction Typical problem: build a VD for a set of points in the plane. Consider 3D, build a paraboloid, lift/project points (sites) onto the paraboloid Construct half-spaces tangent to paraboloid at those points. Construct intersection of these half-spaces Projection of these intersections down on the plane gives the VD of initial sites.

Geometric decomposition Reduce more complex problem to a subset of simpler problems, i.e. in polygon intersection problem, compute rough intersection first and then proceed to find more precise intersection through more elaborate computational methods.

Review Provide principle of work and examples of algorithm strategies: Incremental Divide-and-conquer Sweep-line/plane Dimension reduction Geometric decomposition