UMass Lowell Computer Science 91.503 Analysis of Algorithms Prof. Karen Daniels Spring, 2005 Lecture 1 (Part 2) “How to Make an Algorithm Sandwich” adapted.

Slides:



Advertisements
Similar presentations
Heuristics for the Hidden Clique Problem Robert Krauthgamer (IBM Almaden) Joint work with Uri Feige (Weizmann)
Advertisements

CPE702 Complexity Classes Pruet Boonma Department of Computer Engineering Chiang Mai University Based on Material by Jenny Walter.
8/29/06CS 6463: AT Computational Geometry1 CS 6463: AT Computational Geometry Spring 2006 Convex Hulls Carola Wenk.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2001 Midterm Review Fri. Oct 26.
UMass Lowell Computer Science Graduate Analysis of Algorithms Prof. Karen Daniels Spring, 2010 Lecture 3 Tuesday, 2/9/10 Amortized Analysis.
Computational problems, algorithms, runtime, hardness
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2001 Lecture 1 (Part 1) Introduction/Overview Tuesday, 9/4/01.
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, Center Decision Problem.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2001 Lecture 6 Tuesday, 10/16/01 NP-Completeness, Part 2.
CS 206 Introduction to Computer Science II 09 / 10 / 2008 Instructor: Michael Eckmann.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Spring, 2005 Lecture 1 (Part 1) Introduction/Overview Tuesday, 1/25/05.
UMass Lowell Computer Science Graduate Analysis of Algorithms Prof. Karen Daniels Spring, 2005 Lecture 3 Tuesday, 2/8/05 Amortized Analysis.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2004 Lecture 6 Wednesday, 10/13/04 NP-Completeness.
CPSC 689: Discrete Algorithms for Mobile and Wireless Systems Spring 2009 Prof. Jennifer Welch.
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2007 Lecture 3 Chapter 3: 2D Convex Hulls Friday,
Complexity Analysis (Part I)
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Spring, 2003 Review Lecture Tuesday, 5/6/03.
UMass Lowell Computer Science Graduate Analysis of Algorithms Prof. Karen Daniels Spring, 2009 Lecture 3 Tuesday, 2/10/09 Amortized Analysis.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2006 Text: Chapter 3 Growth of Functions.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2002 Lecture 1 (Part 1) Introduction/Overview Tuesday, 9/3/02.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2002 Review Lecture Tuesday, 12/10/02.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Spring, 2001 Lectures 3/4 Chapters 1 & 2 Wed. 2/7/01 and Thursday 2/8/01.
Computational Complexity, Physical Mapping III + Perl CIS 667 March 4, 2004.
CS3381 Des & Anal of Alg ( SemA) City Univ of HK / Dept of CS / Helena Wong 2. Analysis of Algorithms - 1 Analysis.
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2007 Lecture 1 Course Introduction.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Spring, 2009 Lecture 1 (Part 2) “How to Make an Algorithm Sandwich” adapted.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2001 Lectures 2, 3 Chapters 1, 2 Fri. 9/7/01 – Mon. 9/10/01.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2000 Final Review Wed. 12/13.
Finding the Largest Area Axis-Parallel Rectangle in a Polygon in O(n log 2 n) Time MATHEMATICAL SCIENCES COLLOQUIUM Prof. Karen Daniels Wednesday, October.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2004 Lecture 1 (Part 1) Introduction/Overview Wednesday, 9/8/04.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Spring, 2006 Lecture 6 Monday, 3/6/06 NP-Completeness.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Spring, 2002 Lecture 1 (Part 1) Introduction/Overview Tuesday, 1/29/02.
1 Introduction to Approximation Algorithms Lecture 15: Mar 5.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Spring, 2001 Final Review Mon. 5/14-Wed. 5/16.
Summary of Algo Analysis / Slide 1 Algorithm complexity * Bounds are for the algorithms, rather than programs n programs are just implementations of an.
Text Chapters 1, 2. Sorting ä Sorting Problem: ä Input: A sequence of n numbers ä Output: A permutation (reordering) of the input sequence such that:
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2002 Lecture 6 Tuesday, 10/8/02 NP-Completeness.
Algorithms. Introduction The methods of algorithm design form one of the core practical technologies of computer science. The main aim of this lecture.
Analysis of Algorithms Spring 2015CS202 - Fundamentals of Computer Science II1.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Spring, 2002 Lecture 1 Introduction/Overview Text: Chapters 1, 2 Thurs.
CSC 201 Analysis and Design of Algorithms Lecture 03: Introduction to a CSC 201 Analysis and Design of Algorithms Lecture 03: Introduction to a lgorithms.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Spring, 2010 Lecture 6 Tuesday, 3/23/10 NP-Completeness 1.
Complexity Classes (Ch. 34) The class P: class of problems that can be solved in time that is polynomial in the size of the input, n. if input size is.
Lecture 2 Computational Complexity
1 Introduction to Approximation Algorithms. 2 NP-completeness Do your best then.
Tonga Institute of Higher Education Design and Analysis of Algorithms IT 254 Lecture 8: Complexity Theory.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 4.
Algorithms Lecture 1. Introduction The methods of algorithm design form one of the core practical technologies of computer science. The main aim of this.
Introduction to Algorithms Lecture 1. Introduction The methods of algorithm design form one of the core practical technologies of computer science. The.
Major objective of this course is: Design and analysis of modern algorithms Different variants Accuracy Efficiency Comparing efficiencies Motivation thinking.
CSC 413/513: Intro to Algorithms NP Completeness.
CS 206 Introduction to Computer Science II 09 / 18 / 2009 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 01 / 30 / 2009 Instructor: Michael Eckmann.
CSCE 411H Design and Analysis of Algorithms Set 10: Lower Bounds Prof. Evdokia Nikolova* Spring 2013 CSCE 411H, Spring 2013: Set 10 1 * Slides adapted.
CS6045: Advanced Algorithms NP Completeness. NP-Completeness Some problems are intractable: as they grow large, we are unable to solve them in reasonable.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2001 Review Lecture Tuesday, 12/11/01.
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.
BITS Pilani Pilani Campus Data Structure and Algorithms Design Dr. Maheswari Karthikeyan Lecture1.
The NP class. NP-completeness Lecture2. The NP-class The NP class is a class that contains all the problems that can be decided by a Non-Deterministic.
Analysis of Algorithms Spring 2016CS202 - Fundamentals of Computer Science II1.
The 2x2 Simple Packing Problem André van Renssen Supervisor: Bettina Speckmann.
Advanced Algorithms Analysis and Design
P & NP.
Lecture 1 (Part 1) Introduction/Overview Tuesday, 9/9/08
Approximation Algorithms
Objective of This Course
Ch 4: Recurrences Ming-Te Chi
UMass Lowell Computer Science Analysis of Algorithms Prof
Complexity Theory: Foundations
Presentation transcript:

UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Spring, 2005 Lecture 1 (Part 2) “How to Make an Algorithm Sandwich” adapted from the fall, 2000 talk Finding the Largest Area Axis-Parallel Rectangle in a Polygon in O(n log 2 n) Time given at UMass Lowell MATHEMATICAL SCIENCES COLLOQUIUM

Context: Taxonomy of Problems Supporting Apparel Manufacturing OrderedContainment Geometric Restriction Distance-BasedSubdivision MaximumRectangle Limited Gaps MinimalEnclosure Column-Based Layout Two-Phase Layout LatticePacking Containment Maximal Cover

A Common (sub)Problem Find a Good Approximation Outer Inner

ä Given a 2D polygon that: ä does not intersect itself ä may have holes ä has n vertices ä Find the Largest-Area Axis-Parallel Rectangle ä How “hard” is it? ä How “fast” can we find it? What’s the Problem?

ä Explore the problem to gain intuition: ä Describe it: What are the assumptions? (model of computation, etc...) ä Has it already been solved? ä Have similar problems been solved? ( more on this later ) ä What does best-case input look like? ä What does worst-case input look like? ä Establish worst-case upper bound on the problem using an algorithm ä Design a (simple) algorithm and find an upper bound on its worst-case asymptotic running time; this tells us problem can be solved in a certain amount of time. Algorithms taking more than this amount of time may exist, but won’t help us. ä Establish worst-case lower bound on the problem ä Tighten each bound to form a worst-case “sandwich” Approach increasing worst-case asymptotic running time as a function of n n 1 2n2n2n2n n2n2n2n2 n3n3n3n3 n4n4n4n4 n5n5n5n5

Upper Bound First Attempt

Designing an Algorithm to Provide Upper Bound Contacts reduce degrees of freedom ä First attempt uses a straightforward approach: ä “brute-force” ä “naïve” ä Will most likely produce a “loose” upper bound ä Characterize rectangle based on how it can “grow”

O(n 5 ) LR Algorithm Find_LR(Polygon P) area0 Find_LR_0_RC(P) area0 Find_LR_0_RC(P) area1 Find_LR_1_RC(P) area1 Find_LR_1_RC(P) area2 Find_LR_2_RC(P) area2 Find_LR_2_RC(P) area3 Find_LR_3_RC(P) area3 Find_LR_3_RC(P) area4 Find_LR_4_RC(P) area4 Find_LR_4_RC(P) return maximum(area0, area1, area2, area3, area4) return maximum(area0, area1, area2, area3, area4)Find_LR_0_RC(P) for i 1 to n (for each edge of P) for j 1 to n for j 1 to n for k 1 to n for k 1 to n for l 1 to n for l 1 to n area area of LR for 0-RC determining set for (i,j,k,l) area area of LR for 0-RC determining set for (i,j,k,l) if LR is empty, then update maximum area if LR is empty, then update maximum area return maximum area return maximum area O(n) O(n 5 )

First Upper Bound: What can we really conclude? ä Algorithm’s worst-case running time is in O(n 5 ). ä Problem can be solved in O(n 5 ) time, even for worst-case inputs. ä Note: there might exist algorithms for this problem that take more than n 5 time, but they aren’t useful to us!  If a worst-case input exists that causes algorithm to actually use time proportional to n 5, then algorithm’s worst-case running time is also in  (n 5 ).  In this case, we can say algorithm’s worst-case running time is in  (n 5 ). n 1 n2n2n2n2 2n2n2n2n n5n5n5n5 increasing worst-case asymptotic running time as a function of n An inefficient algorithm for the problem might exist that takes this much time, but would not help us.

Lower Bound First Attempt n 1 n2n2n2n2 2n2n2n2n n5n5n5n5 increasing worst-case asymptotic running time as a function of n An inefficient algorithm for the problem might exist that takes this much time, but would not help us.

First Attempt ä First attempt will most likely produce a “loose” lower bound that can be improved later.   (1) and  (n) are not hard to achieve:  Rationale for  (n) is that we must examine every vertex at least once in order to solve the problem. This holds for every algorithm that solves the problem, so it gives us a lower bound on the problem in an even stronger sense than our upper bound. ä Remember that our upper bound does not guarantee that no algorithm exists for this problem that takes more than O(n 5 ) time, but if one exists it will not help us! n 1 2n2n2n2n n5n5n5n5 worst-case bounds on problem on problem An inefficient algorithm for the problem might exist that takes this much time, but would not help us. No algorithm for the problem exists that can solve it for worst-case inputs in less than linear time.

Know the Difference! n 1 2n2n2n2n n5n5n5n5 worst-case bounds on problem on problem An inefficient algorithm for the problem might exist that takes this much time, but would not help us. No algorithm for the problem exists that can solve it for worst-case inputs in less than linear time. Strong Bound: This worst-case lower bound on the problem holds for every algorithm that solves the problem and abides by our problem’s assumptions. Weak Bound: This worst-case upper bound on the problem comes from just considering one algorithm. Other, less efficient algorithms that solve this problem might exist, but we don’t care about them! Both the upper and lower bounds are probably loose (i.e. probably can be tightened later on).

Upper Bound Tightening It

ä Think harder… ä Design an algorithm that takes only O(n 2 ) time for worst-case inputs Approach 1 2n2n2n2n n5n5n5n5 n worst-case bounds on problem on problem n2n2n2n2 Now we no longer care about this one! tighter upper bound

ä Think even harder… ä Run into brick wall! ä Characterize the brick wall: this type of case ä Go around brick wall by looking at similar problems. ä This requires ability to compare functions! Approach (continued) n 1 2n2n2n2n n5n5n5n5 worst-case bounds on problem on problem n2n2n2n2

Some Related Problems n 1 n log(n) n log 2 (n) 2n2n2n2n n5n5n5n5 n  (n) log(n) n  (n)

Some Related Problems (continued) n 1 n log(n) n log 2 (n) 2n2n2n2n n5n5n5n5 n  (n) log(n) n  (n)

ä Reduce the O(n 2 ) bound to O(n log 2 n): ä Adapt a technique that worked for a similar problem in order to develop a general framework for the problematic case Approach (continued) n 1 2n2n2n2n n5n5n5n5 worst-case bounds on problem on problem n2n2n2n2 n log 2 n

Lower Bound Tightening It

Approach ä Go around lower bound brick wall by: ä examining strong lower bounds for some similar problems ä transforming a similar problem to our problem [this process is similar to what we do when we prove problems NP-complete] n 1 2n2n2n2n n5n5n5n5 worst-case bounds on problem on problem n2n2n2n2 n log 2 n

Lower Bounds for Related Problems n1 n log(n) n log 2 (n) 2n2n2n2n n5n5n5n5 SmallestOuterRectangle:   (n) SmallestOuterCircle:   (n) LargestInnerRectangle:   (n) LargestInnerCircle:   (n log n) point set, polygon point set polygon LargestInnerRectangle:   (n log 2 (n))polygon worst-case bounds on our problem Largest circle containing no points of the set & whose center is in convex hull of the points

Lower Bound of  (n log n) by Transforming a ( seemingly unrelated ) Problem MAX-GAP instance: given n real numbers { x 1, x 2,... x n } find the maximum difference between 2 consecutive numbers in the sorted list. O(n) time transformation specialized polygon x2x2x2x2 x4x4x4x4 x3x3x3x3 x1x1x1x1 Rectangle area is a solution to the MAX-GAP instance Rectangle algorithm must take as least as much time as MAX-GAP. MAX-GAP is known to be in  (n log n). Rectangle algorithm must take  (n log n) time for specialized polygons. [Transforming yet another different problem yields bound for unspecialized polygons.]

ä First attempt: ä Establish weak (and loose) worst-case upper bound on the problem using an algorithm ä Establish strong (and loose) worst-case lower bound on the problem ä Tighten bounds to make an “algorithm sandwich” ä Establish weak (but tighter) worst-case O(n log 2 n) upper bound on the problem using an algorithm ä Establish strong (and tighter) worst-case lower bound on the problem by transforming a problem with known lower bound Summary n1 n log(n) n log 2 (n) 2n2n2n2n n5n5n5n5 bounds on problem

Recent Improvement! ä “Finding the Largest Axis-Aligned Rectangle in a Polygon in O(n log n) Time” ä Ralph Boland, Jorge Urrutia ä Canadian Conference on Computational Geometry, August 13-15, 2001 n1 n log(n) n log 2 (n) 2n2n2n2n n5n5n5n5 bounds on problem n1 n log(n) n log 2 (n) 2n2n2n2n n5n5n5n5 Tight bound on problem

For More Information ä Computational Geometry: ä Graduate CS course in Computational Geometry offered at UMass Lowell in Spring ’01, Spring ‘04 ä Introductory texts: ä Computational Geometry in C (O’Rourke) ä Computational Geometry: An Introduction (Preparata & Shamos) ä Bibliography: ftp://ftp.cs.usask.ca/pub/geometry/ ä Software: ä My research: ä ä Journal paper: “Finding the largest area axis-parallel rectangle in a polygon” ä (Computational Geometry: Theory and Applications) ä Prof. Victor Milenkovic: Frequent co-author and former PhD advisor ä