CS 473G Algorithmsx

Total Page:16

File Type:pdf, Size:1020Kb

CS 473G Algorithmsx CS 473g Algorithms¬ Sariel Har-Peled December 7, 2009 ­This work is licensed under the Creative Commons Attribution-Noncommercial 3.0 License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/3.0/ or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA. 2 Contents Preface 11 I NP Completeness 13 1 NP Completeness I 15 1.1 Introduction . 15 1.2 Complexity classes . 17 1.2.1 Reductions . 18 1.3 More NP-Complete problems . 19 1.3.1 3SAT ..................................... 19 1.4 Bibliographical Notes . 21 2 NP Completeness II 23 2.1 Max-Clique . 23 2.2 Independent Set . 25 2.3 Vertex Cover . 25 2.4 Graph Coloring . 26 3 NP Completeness III 29 3.1 Hamiltonian Cycle . 29 3.2 Traveling Salesman Problem . 30 3.3 Subset Sum . 31 3.4 3 dimensional Matching (3DM) . 32 3.5 Partition . 33 4 Dynamic programming 35 4.1 Basic Idea - Partition Number . 35 4.1.1 Memoization: . 37 4.2 Fibonacci numbers . 38 4.3 Edit Distance . 39 5 Dynamic programming II - The Recursion Strikes Back 43 5.1 Optimal Search Trees . 43 5.2 Optimal Triangulations . 45 3 5.3 Matrix Multiplication . 46 5.4 Longest Ascending Subsequence . 47 5.5 Pattern Matching . 47 6 Approximation algorithms 49 6.1 Greedy algorithms and approximation algorithms . 49 6.1.1 Alternative algorithm – two for the price of one . 51 6.2 Traveling Salesman Person . 51 6.2.1 TSP with the triangle inequality . 52 6.2.1.1 A 2-approximation . 52 6.2.1.2 A 3=2-approximation to TSP ,-Min . 53 4 6.3 Biographical Notes . 55 7 Approximation algorithms II 57 7.1 Max Exact 3SAT . 57 7.2 Approximation Algorithms for Set Cover . 58 7.2.1 Guarding an Art Gallery . 58 7.2.2 Set Cover . 59 7.3 Biographical Notes . 60 8 Approximation algorithms III 61 8.1 Clustering . 61 8.1.1 The approximation algorithm for k-center clustering . 62 8.2 Subset Sum . 64 8.2.1 On the complexity of "-approximation algorithms . 65 8.2.2 Approximating subset-sum . 65 8.2.2.1 Bounding the running time of ApproxSubsetSum ........ 67 8.2.2.2 The result . 67 8.3 Approximate Bin Packing . 68 8.4 Bibliographical notes . 68 II Randomized Algorithms 69 9 Randomized Algorithms 71 9.1 Some Probability . 71 9.2 Sorting Nuts and Bolts . 72 9.2.1 Running time analysis . 72 9.2.1.1 Alternative incorrect solution . 73 9.2.2 What are randomized algorithms? . 73 9.3 Analyzing QuickSort . 74 10 Randomized Algorithms II 77 10.1 QuickSort with High Probability . 77 10.1.1 Proving that an elements participates in small number of rounds. 77 10.2 Chernoff inequality . 79 4 10.2.1 Preliminaries . 79 10.2.2 Chernoff inequality . 79 10.2.2.1 The Chernoff Bound — General Case . 81 11 Min Cut 83 11.1 Min Cut . 83 11.1.1 Problem Definition . 83 11.1.2 Some Definitions . 83 11.2 The Algorithm . 84 11.2.1 Analysis . 86 11.2.1.1 The probability of success. 86 11.2.1.2 Running time analysis. 87 11.3 A faster algorithm . 87 11.4 Bibliographical Notes . 90 III Network Flow 91 12 Network Flow 93 12.1 Network Flow . 93 12.2 Some properties of flows, max flows, and residual networks . 94 12.3 The Ford-Fulkerson method . 97 12.4 On maximum flows . 98 13 Network Flow II - The Vengeance 101 13.1 Accountability . 101 13.2 Ford-Fulkerson Method . 101 13.3 The Edmonds-Karp algorithm . 102 13.4 Applications and extensions for Network Flow . 104 13.4.1 Maximum Bipartite Matching . 104 13.4.2 Extension: Multiple Sources and Sinks . 105 14 Network Flow III - Applications 107 14.1 Edge disjoint paths . 107 14.1.1 Edge-disjoint paths in a directed graphs . 107 14.1.2 Edge-disjoint paths in undirected graphs . 108 14.2 Circulations with demands . 109 14.2.1 Circulations with demands . 109 14.2.1.1 The algorithm for computing a circulation . 110 14.3 Circulations with demands and lower bounds . 110 14.4 Applications . 111 14.4.1 Survey design . 111 5 15 Network Flow IV - Applications II 113 15.1 Airline Scheduling . 113 15.1.1 Modeling the problem . 114 15.1.2 Solution . 114 15.2 Image Segmentation . 115 15.3 Project Selection . 117 15.3.1 The reduction . 118 15.4 Baseball elimination . 119 15.4.1 Problem definition . 119 15.4.2 Solution . 120 15.4.3 A compact proof of a team being eliminated . 120 IV Min Cost Flow 123 16 Network Flow V - Min-cost flow 125 16.1 Minimum Average Cost Cycle . 125 16.2 Potentials . 127 16.3 Minimum cost flow . 128 16.4 A Strongly Polynomial Time Algorithm for Min-Cost Flow . 130 16.5 Analysis of the Algorithm . 131 16.5.1 Reduced cost induced by a circulation . 132 16.5.2 Bounding the number of iterations . 132 16.6.
Recommended publications
  • Parallel Techniques for Paths, Visibility, and Related Problems (Thesis)
    Purdue University Purdue e-Pubs Department of Computer Science Technical Reports Department of Computer Science 1992 Parallel Techniques for Paths, Visibility, and Related Problems (Thesis) Ziyi Danny Chen Report Number: 92-051 Chen, Ziyi Danny, "Parallel Techniques for Paths, Visibility, and Related Problems (Thesis)" (1992). Department of Computer Science Technical Reports. Paper 972. https://docs.lib.purdue.edu/cstech/972 This document has been made available through Purdue e-Pubs, a service of the Purdue University Libraries. Please contact [email protected] for additional information. PARALLEL TECHNIQUES FOR PATHS, VISIBILITY, AND RELATED PROBLEMS Ziyi Danny Chen CSD·TR-92·0S1 August 1992 PARALLEL TECHNIQUES FOR PATHS, VISIBILITY, AND RELATED PROBLEMS A Thesis Submitted to the Faculty of Purdue University by Ziyi Danny Chen In Partial Fulfillment of the Requirements for the Degree of Doctor of Philosophy August 1992 11 To the memory of my father III ACKNOWLEDGMENTS There are many people that I would like to thank. First, I would like to express my greatest appreciation to my major professor Mikhail J. Atallah. He has always given me the freedom to develop my own research interest and at the same time provided all the support, guidance, and encouragement I needed. Learning how to do research from him and discussing problems with him have become some of my most joyful experience at Purdue. Furthermore, I am greatly indebted to Professor Greg N. Frederickson and Professor Susanne E. Hambrusch, for serving as my committee members and for giving me many needed suggestions and helps during my study at Purdue. I also like to thank Professor Christoph M.
    [Show full text]
  • 30 POLYGONS Joseph O’Rourke, Subhash Suri, and Csaba D
    30 POLYGONS Joseph O'Rourke, Subhash Suri, and Csaba D. T´oth INTRODUCTION Polygons are one of the fundamental building blocks in geometric modeling, and they are used to represent a wide variety of shapes and figures in computer graph- ics, vision, pattern recognition, robotics, and other computational fields. By a polygon we mean a region of the plane enclosed by a simple cycle of straight line segments; a simple cycle means that nonadjacent segments do not intersect and two adjacent segments intersect only at their common endpoint. This chapter de- scribes a collection of results on polygons with both combinatorial and algorithmic flavors. After classifying polygons in the opening section, Section 30.2 looks at sim- ple polygonizations, Section 30.3 covers polygon decomposition, and Section 30.4 polygon intersection. Sections 30.5 addresses polygon containment problems and Section 30.6 touches upon a few miscellaneous problems and results. 30.1 POLYGON CLASSIFICATION Polygons can be classified in several different ways depending on their domain of application. In chip-masking applications, for instance, the most commonly used polygons have their sides parallel to the coordinate axes. GLOSSARY Simple polygon: A closed region of the plane enclosed by a simple cycle of straight line segments. Convex polygon: The line segment joining any two points of the polygon lies within the polygon. Monotone polygon: Any line orthogonal to the direction of monotonicity inter- sects the polygon in a single connected piece. Star-shaped polygon: The entire polygon is visible from some point inside the polygon. Orthogonal polygon: A polygon with sides parallel to the (orthogonal) coordi- nate axes.
    [Show full text]
  • Minimum Rectilinear Polygons for Given Angle Sequences ∗
    Minimum Rectilinear Polygons for Given Angle Sequences ∗ William S. Evansyz Krzysztof Fleszarx Philipp Kindermann{k Noushin Saeediy∗∗ Chan-Su Shinyy Alexander Wolff {zz Abstract A rectilinear polygon is a polygon whose edges are axis-aligned. Walking counterclock- wise on the boundary of such a polygon yields a sequence of left turns and right turns. The number of left turns always equals the number of right turns plus 4. It is known that any such sequence can be realized by a rectilinear polygon. In this paper, we consider the problem of finding realizations that minimize the perimeter or the area of the polygon or the area of the bounding box of the polygon. We show that all three problems are NP-hard in general. This answers an open question of Patrignani [CGTA 2001], who showed that it is NP-hard to minimize the area of the bounding box of an orthogonal drawing of a given planar graph. We also show that realizing polylines with minimum bounding box area is NP-hard. Then we consider the special cases of x-monotone and xy-monotone rectilinear polygons. For these, we can optimize the three objectives efficiently. 1 Introduction In this paper, we consider the problem of computing, for a given rectilinear angle sequence, a \small" rectilinear polygon that realizes the sequence. A rectilinear angle sequence S is a sequence of left (+90◦) turns, denoted by L, and right (−90◦) turns, denoted by R. We n write S = (s1; : : : ; sn) 2 fL; Rg , where n is the length of S. As we consider only rectilinear angle sequences, we usually drop the term \rectilinear." A polygon P realizes an angle sequence S if there is a counterclockwise (ccw) walk along the boundary of P such that the turns at the vertices of P , encountered during the walk, form the sequence S.
    [Show full text]
  • Optimal Uniformly Monotone Partitioning of Polygons with Holes
    Computer-Aided Design 44 (2012) 1235–1252 Contents lists available at SciVerse ScienceDirect Computer-Aided Design journal homepage: www.elsevier.com/locate/cad Optimal uniformly monotone partitioning of polygons with holes Xiangzhi Wei a, Ajay Joneja a,∗, David M. Mount b a Department of Industrial Engineering and Logistics Management, Hong Kong University of Science and Technology, Clear Water Bay, Kowloon, Hong Kong b Department of Computer Science and Institute for Advanced Computer Studies, University of Maryland, College Park, MD, USA article info a b s t r a c t Article history: Polygon partitioning is an important problem in computational geometry with a long history. In this Received 15 November 2011 paper we consider the problem of partitioning a polygon with holes into a minimum number of uniformly Accepted 11 June 2012 monotone components allowing arbitrary Steiner points. We call this the MUMC problem. We show that, given a polygon with n vertices and h holes and a scan direction, the MUMC problem relative to this Keywords: direction can be solved in time O.n log nCh log3 h/. Our algorithm produces a compressed representation Polygon subdivision of the subdivision of size O.n/, from which it is possible to extract either the entire decomposition or just Uniformly monotone subdivision the boundary of any desired component, in time proportional to the output size. When the scan direction Simple polygons 3 Network flow is not given, the problem can be solved in time O.K.n log n C h log h//, where K is the number of edges Planar graphs in the polygon's visibility graph.
    [Show full text]
  • Triangulating Polygons
    TRIANGULATING POLYGONS Vera Sacrist´an Computational Geometry Facultat d'Inform`aticade Barcelona Universitat Politcnica de Catalunya TRIANGULATING POLYGONS Computational Geometry, Facultat d'Inform`aticade Barcelona, UPC TRIANGULATING POLYGONS A polygon triangulation is the decomposition of a polygon into triangles. This is done by inserting internal diagonals. An internal diagonal is any segment... • connecting two vertices of the polygon and • completely enclosed in the polygon. Computational Geometry, Facultat d'Inform`aticade Barcelona, UPC TRIANGULATING POLYGONS A polygon triangulation is the decomposition of a polygon into triangles. This is done by inserting internal diagonals. An internal diagonal is any segment... • connecting two vertices of the polygon and • completely enclosed in the polygon. Computational Geometry, Facultat d'Inform`aticade Barcelona, UPC TRIANGULATING POLYGONS A polygon triangulation is the decomposition of a polygon into triangles. This is done by inserting internal diagonals. An internal diagonal is any segment... • connecting two vertices of the polygon and • completely enclosed in the polygon. Computational Geometry, Facultat d'Inform`aticade Barcelona, UPC TRIANGULATING POLYGONS A polygon triangulation is the decomposition of a polygon into triangles. This is done by inserting internal diagonals. An internal diagonal is any segment... • connecting two vertices of the polygon and • completely enclosed in the polygon. Computational Geometry, Facultat d'Inform`aticade Barcelona, UPC TRIANGULATING POLYGONS A polygon triangulation is the decomposition of a polygon into triangles. This is done by inserting internal diagonals. An internal diagonal is any segment... • connecting two vertices of the polygon and • completely enclosed in the polygon. Computational Geometry, Facultat d'Inform`aticade Barcelona, UPC TRIANGULATING POLYGONS A polygon triangulation is the decomposition of a polygon into triangles.
    [Show full text]
  • Multi-Goal Path Planning for Cooperative Sensing
    CZECH TECHNICAL UNIVERSITY IN PRAGUE FACULTY OF ELECTRICAL ENGINEERING Doctoral Thesis February, 2010 Jan Faigl CZECH TECHNICAL UNIVERSITY IN PRAGUE FACULTY OF ELECTRICAL ENGINEERING DEPARTMENT OF CYBERNETICS GERSTNER LABORATORY MULTI-GOAL PATH PLANNING FOR COOPERATIVE SENSING Doctoral Thesis Jan Faigl Prague, February, 2010 Ph.D. Programme: Electrical Engineering and Information Technology Branch of study: Artificial Intelligence and Biocybernetics Supervisor: Ing. Libor Pˇreuˇcil,CSc. Abstract The thesis deals with the multi-goal path planning problem. The problem is studied in the context of the inspection task of cooperating robots in a search and rescue mission. Two models of the sensing are considered: continuous and discrete. An environment is a priori known and it is represented by a polygonal domain in both approaches. The con- tinuous sensing assumes relatively inexpensive cost of sensing in comparison to the cost of motion and can be formulated as the Watchman Route Problem (WRP). The discrete sensing leads to the decoupled approach that is motivated by problems where the cost of sensing is dominant. The decoupled approach consists of two problems: the problem of finding minimal set of sensing locations, and the multi-goal path planning problem to find a path visiting the found locations. The set of sensing locations can be found as a solution of the Art Gallery Problem (AGP) or sensor placement problem if additional vis- ibility constraints have to be considered, e.g. visibility range, incident angle. The multi- goal path planning problem can be formulated as the Traveling Salesman Problem (TSP) in which paths between cities have to be traversable by the robot.
    [Show full text]
  • Fast Geometric Algorithms
    FAST GEOMETRICALGORITHMS by Mark T. Noga Dissertation submitted to the Faculty of the Yi rgin ia Polytechnic Institute and State University in partial fulfillment of the requirements for the degree of DOCTOR OF PH I LOSO PHY in Computer Science and Applications APPROVED: D.C.S. Allison D. P. Rosel le R.M. Haralick R.W. Ehrich J .W. Roach January, 1984 Blacksburg, Virginia To Naida ii WORDS OF THANKS "I' II note you in my book of memory." - William Shakespeare, King Henry VI This thesis describes the culmination of five years of prolonged study at Virginia Polytechnic Institute. During that time, have benefitted from the close companionship of many people from all different parts of the United States and the world. Without your concern, understanding, encouragement, wisdom, and prodding, completion of this document would have been an all but impossible task. To all my friends I would Ii ke to say "thank you." Some of you gave more than what one would normally expect out of friendship and curiosity, and it is an honor for me to acknowledge these individually (and not in any special order). Occasionally you meet an individual who has the ability to take several seemingly unrelated results and somehow combine them to form what is often a colorful and unique solution to a particular problem. Doug Smith is one of these rare individuals. We spent many hours discussing, amongst other things, why art is pleasing to the eye (the entropy of art), or what features programming languages would contain in the year 2050 (or even if they would exist in a form equivalent to today's languages).
    [Show full text]
  • Algorithm for Triangulating a Simple Polygon
    On the Agenda Computational Geometry The Art Gallery Problem Polygon Triangulation Chapter 3 Polygons and Triangulation 13. 23. Art Gallery Problem Observations Given a simple polygon P, say The entire interior of a convex that two points p and q can see polygon is visible from any each other if the open segment pq R interior point. lies entirely within P. p q A point guards a region R ⊆ P if p convex sees all q∈R. Given a polygon P, what is the p non star-shaped minimal number of guards required A star-shaped polygon requires to guard P, and what are their only one guard located in its locations ? kernel . (actually this is the definition of a star-shape star-shaped polygon) 33. 43. Art Gallery Problem – Easy Upper Diagonals in Polygons Bound A diagonal of a polygon P is a line segment connecting two non-adjacent vertices, which lies entirely within P. Theorem: Any polygon with n>3 vertices n-2 guards suffice: has a diagonal, which may be found in Subdivide the polygon into n-2 O( n) time. triangles (triangulation) u Proof: Find the leftmost vertex v. Connect (we will show that this is the correct number of triangles) its two neighbors u and w. If this is not a diagonal there are other vertices inside v Place one guard in each triangle. the triangle uvw. Connect v to the vertex v’ v’ furthest from the (line containing the) w Theorem : Any simple planar polygon segment uw . with n vertices has a triangulation of size n-2.
    [Show full text]
  • Computational Geometry Fall 2002
    CMSC 754: Computational Geometry Fall 2002 http://www.cs.umd.edu/~mount/754/ Instructor: Dave Mount. Office: AVW 3209. Email: [email protected]. Office phone: (301) 405–2704. Office hours: Mon 3:00–4:00, Wed 3:30–4:30. I am also available immediately after class for questions. Feel free to send me email if you cannot make these times to set up another time. Teaching Assistant: Justin Wan. Office: AVW 1151. Email: [email protected]. Office hours: Mon 2:30–3:30, Thu 5:00–6:00. Class Time: Tue, Thur 2:00-3:15. Room: CSI 1122. Course Objectives: This is an introductory course to computational geometry and its appli- cations. We will discuss techniques needed in designing and analyzing efficient algorithms for problems in geometry, including convex hulls, geometric intersections, Voronoi diagrams, Delaunay triangulations, geometric data structures, and motion planning. Text: (Required) Computational Geometry: Algorithms and Applications (2nd Edition), M. de Berg, M. van Kreveld, M. Overmars, O. Schwarzkopf, Springer-Verlag, 2000. Prerequisites: CMSC 451, or its equivalent. • Knowledge of basic algorithm design techniques, such as divide-and-conquer, greedy algorithms, dynamic programming, • Knowledge of basic analysis techniques such as asymptotic notation, solving summations and recurrences, basic probability theory. • Knowledge of basic data structures (e.g. balanced binary trees and heaps). Course Work: There will be roughly 5 homework assignments. Normally, late homeworks will not be accepted. If you think that you have a legitimate excuse for handing in a homework late, contact me before the due date. There will be a midterm and comprehensive final exam.
    [Show full text]