The Algorithm Design Manual

Similar documents
Thomas H. Cormen Charles E. Leiserson Ronald L. Rivest. Introduction to Algorithms

Computational Discrete Mathematics

About the Author. Dependency Chart. Chapter 1: Logic and Sets 1. Chapter 2: Relations and Functions, Boolean Algebra, and Circuit Design

Analysis of Algorithms

Introduction to Algorithms Third Edition

4.1.2 Merge Sort Sorting Lower Bound Counting Sort Sorting in Practice Solving Problems by Sorting...

DESIGN AND ANALYSIS OF ALGORITHMS

CLASS: II YEAR / IV SEMESTER CSE CS 6402-DESIGN AND ANALYSIS OF ALGORITHM UNIT I INTRODUCTION

CSCE 321/3201 Analysis and Design of Algorithms. Prof. Amr Goneid. Fall 2016

Anany Levitin 3RD EDITION. Arup Kumar Bhattacharjee. mmmmm Analysis of Algorithms. Soumen Mukherjee. Introduction to TllG DCSISFI &

CS-6402 DESIGN AND ANALYSIS OF ALGORITHMS

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Question Bank Subject Name: CS6402- Design & Analysis of Algorithm Year/Sem : II/IV UNIT-I INTRODUCTION

Algorithms and Data Structures

Chapter 9 Graph Algorithms

Chapter 9 Graph Algorithms

Lecture 1. Introduction

Chapter 9 Graph Algorithms

11/22/2016. Chapter 9 Graph Algorithms. Introduction. Definitions. Definitions. Definitions. Definitions

Fundamentals of Discrete Mathematical Structures

Data Structures and Algorithms

r=1 The Binomial Theorem. 4 MA095/98G Revision

Department of Computer Applications. MCA 312: Design and Analysis of Algorithms. [Part I : Medium Answer Type Questions] UNIT I

Lecture 13. Reading: Weiss, Ch. 9, Ch 8 CSE 100, UCSD: LEC 13. Page 1 of 29

Lecture 24: More Reductions (1997) Steven Skiena. skiena

Review for Midterm Exam

Theorem 2.9: nearest addition algorithm

Applied Combinatorics

Subject Index. Journal of Discrete Algorithms 5 (2007)

MATHEMATICAL STRUCTURES FOR COMPUTER SCIENCE

Notation Index. Probability notation. (there exists) (such that) Fn-4 B n (Bell numbers) CL-27 s t (equivalence relation) GT-5.

Introductory Combinatorics

Notation Index 9 (there exists) Fn-4 8 (for all) Fn-4 3 (such that) Fn-4 B n (Bell numbers) CL-25 s ο t (equivalence relation) GT-4 n k (binomial coef

Contents. 1 Introduction. 2 Searching and Traversal Techniques. Preface... (vii) Acknowledgements... (ix)

F. THOMSON LEIGHTON INTRODUCTION TO PARALLEL ALGORITHMS AND ARCHITECTURES: ARRAYS TREES HYPERCUBES

LOGIC AND DISCRETE MATHEMATICS

Introduction to Combinatorial Algorithms

5105 BHARATHIDASAN ENGINEERING COLLEGE

Lecture 3. Brute Force

Data Structures and Algorithm Analysis in C++

THE DESIGN AND ANALYSIS OF COMPUTER ALGORITHMS

Design and Analysis of Algorithms. Comp 271. Mordecai Golin. Department of Computer Science, HKUST

Problem Score Maximum MC 34 (25/17) = 50 Total 100

DESIGN AND ANALYSIS OF ALGORITHMS

Topic Analysis PART-A

INDEX. Cambridge University Press How to Think About Algorithms Jeff Edmonds Index More information

15CS43: DESIGN AND ANALYSIS OF ALGORITHMS

The Design of Approximation Algorithms

DISCRETE MATHEMATICS

Chapter 1 Introduction

INSTITUTE OF AERONAUTICAL ENGINEERING

CSE 100: B+ TREE, 2-3 TREE, NP- COMPLETNESS

COURSE: DATA STRUCTURES USING C & C++ CODE: 05BMCAR17161 CREDITS: 05

L.J. Institute of Engineering & Technology Semester: VIII (2016)

( ) n 5. Test 1 - Closed Book

Index. stack-based, 400 A* algorithm, 325

CS/ENGRD 2110 Object-Oriented Programming and Data Structures Spring 2012 Thorsten Joachims. Lecture 25: Review and Open Problems

Ph.D. Comprehensive Examination Design and Analysis of Algorithms

Discrete Mathematics SECOND EDITION OXFORD UNIVERSITY PRESS. Norman L. Biggs. Professor of Mathematics London School of Economics University of London

Sankalchand Patel College of Engineering - Visnagar Department of Computer Engineering and Information Technology. Assignment

Graph and Digraph Glossary

Computational Geometry Overview from Cormen, et al.

END-TERM EXAMINATION

Reference Sheet for CO142.2 Discrete Mathematics II

ECE250: Algorithms and Data Structures Final Review Course

The Square Root Phenomenon in Planar Graphs

9. Which situation is true regarding a cascading cut that produces c trees for a Fibonacci heap?

1 Format. 2 Topics Covered. 2.1 Minimal Spanning Trees. 2.2 Union Find. 2.3 Greedy. CS 124 Quiz 2 Review 3/25/18

Lecture 1 (Part 1) Introduction/Overview

Virtual University of Pakistan

Reductions. Linear Time Reductions. Desiderata. Reduction. Desiderata. Classify problems according to their computational requirements.

Topic 10 Part 2 [474 marks]

CAD Algorithms. Categorizing Algorithms

1. [1 pt] What is the solution to the recurrence T(n) = 2T(n-1) + 1, T(1) = 1

Dynamic Programming Homework Problems

Search Algorithms. IE 496 Lecture 17

Brute Force: Selection Sort

TOTAL CREDIT UNITS L T P/ S SW/F W. Course Title: Analysis & Design of Algorithm. Course Level: UG Course Code: CSE303 Credit Units: 5

COS 226 Final Exam, Spring 2009

Elementary maths for GMT. Algorithm analysis Part II

APPROXIMATION ALGORITHMS FOR GEOMETRIC PROBLEMS

Course Review for Finals. Cpt S 223 Fall 2008

Algorithm Design Techniques. Hwansoo Han

Heuristic Search. Theory and Applications. Stefan Edelkamp. Stefan Schrodl ELSEVIER. Morgan Kaufmann is an imprint of Elsevier HEIDELBERG LONDON

R13. II B. Tech I Semester Supplementary Examinations, May/June DATA STRUCTURES (Com. to ECE, CSE, EIE, IT, ECC)

CS521 \ Notes for the Final Exam

2. (a) Explain when the Quick sort is preferred to merge sort and vice-versa.

Steven Skiena. skiena

Coping with the Limitations of Algorithm Power Exact Solution Strategies Backtracking Backtracking : A Scenario

Algorithms and Data Structures CS-CO-412

Department of Computer Science & Engineering University of Kalyani. Syllabus for Ph.D. Coursework

Jörgen Bang-Jensen and Gregory Gutin. Digraphs. Theory, Algorithms and Applications. Springer

Model Answer. Section A Q.1 - (20 1=10) B.Tech. (Fifth Semester) Examination Analysis and Design of Algorithm (IT3105N) (Information Technology)

Geometric data structures:

CS6702 GRAPH THEORY AND APPLICATIONS QUESTION BANK

B553 Lecture 12: Global Optimization

Contents. CS 124 Final Exam Practice Problem 5/6/17. 1 Format and Logistics 2

PATH FINDING AND GRAPH TRAVERSAL

Table of Contents. Chapter 1: Introduction to Data Structures... 1

D.K.M.COLLEGE FOR WOMEN (AUTONOMOUS), VELLORE-1.

CLASSIC DATA STRUCTURES IN JAVA

Transcription:

Steven S. Skiena The Algorithm Design Manual With 72 Figures Includes CD-ROM THE ELECTRONIC LIBRARY OF SCIENCE

Contents Preface vii I TECHNIQUES 1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 1.10 2 2.1 2.2 2.3 2.4 Introduction to Algorithms Correctness and Efficiency 1.1.1 Correctness 1.1.2 Efficiency Expressing Algorithms Keeping Score 1.3.1 The RAM Model of Computation 1.3.2 Best, Worst, and Average-Case Complexity The Big Oh Notation Growth Rates Logarithms Modeling the Problem About the War Stories War Story: Psychic Modeling Exercises Data Structures and Sorting Fundamental Data Types 2.1.1 Containers 2.1.2 Dictionaries 2.1.3 Binary Search Trees 2.1.4 Priority Queues Specialized Data Structures Sorting Applications of Sorting 3 4 5 9 9 10 10 11 13 15 16 18 20 21 25 27 28 28 29 30 31 33 33 34

2.5 2.6 2.7 2.8 2.9 3 3.1 3.2 3.3 3.4 3.5 3.6 3.7 4 4.1 4.2 4.3 4.4 4.5 Approaches to Sorting 2.5.1 Data Structures 2.5.2 Incremental Insertion 2.5.3 Divide and Conquer 2.5.4 Randomization 2.5.5 Bucketing Techniques War Story: Stripping Triangulations War Story: Mystery of the Pyramids War Story: String 'em Up Exercises Breaking Problems Down Dynamic Programming 3.1.1 Fibonacci numbers 3.1.2 The Partition Problem 3.1.3 Approximate String Matching 3.1.4 Longest Increasing Sequence 3.1.5 Minimum Weight Triangulation Limitations of Dynamic Programming War Story: Evolution of the Lobster War Story: What's Past Is Prolog War Story: Text Compression for Bar Codes Divide and Conquer 3.6.1 Fast Exponentiation 3.6.2 Binary Search 3.6.3 Square and Other Roots Exercises Graph Algorithms The Friendship Graph Data Structures for Graphs War Story: Getting the Graph Traversing a Graph 4.4.1 Breadth-First Search 4.4.2 Depth-First Search Applications of Graph Traversal 4.5.1 Connected Components 4.5.2 Tree and Cycle Detection 4.5.3 Two-Coloring Graphs 4.5.4 Topological Sorting 4.5.5 Articulation Vertices 36 36 36 37 37 38 39 43 46 50 53 54 54 56 60 62 64 65 66 69 72 75 75 76 76 77 81 82 84 86 88 89 91 92 92 93 93 94 95

Contents xiii 4.6 Modeling Graph Problems 95 4.7 Minimum Spanning Trees 97 4.7.1 Prim's Algorithm 98 4.7.2 Kruskal's Algorithm 99 4.8 Shortest Paths 100 4.8.1 Dijkstra's Algorithm 100 4.8.2 All-Pairs Shortest Path 102 4.9 War Story: Nothing but Nets 102 4.10 War Story: Dialing for Documents 105 4.11 Exercises 110 5 Combinatorial Search and Heuristic Methods 115 5.1 Backtracking 116 5.1.1 Constructing All Subsets 117 5.1.2 Constructing All Permutations 118 5.1.3 Constructing All Paths in a Graph 118 5.2 Search Pruning 119 5.3 Bandwidth Minimization 120 5.4 War Story: Covering Chessboards 122 5.5 Heuristic Methods 125 5.5.1 Simulated Annealing 125 5.5.2 Neural Networks 129 5.5.3 Genetic Algorithms 130 5.6 War Story: Annealing Arrays 131 5.7 Parallel Algorithms 134 5.8 War Story: Going Nowhere Fast 135 5.9 Exercises 136 6 Intractable Problems and Approximations 139 6.1 Problems and Reductions 140 6.2 Simple Reductions 141 6.2.1 Hamiltonian Cycle 142 6.2.2 Independent Set and Vertex Cover 142 6.2.3 Clique and Independent Set 144 6.3 Satisfiability 144 6.3.1 The Theory of NP-Completeness 145 6.3.2 3-Satisfiability 146 6.4 Difficult Reductions 147 6.4.1 Integer Programming 147 6.4.2 Vertex Cover 149

5 Other NP-Complete Problems 151 6 The Art of Proving Hardness 152 7 War Story: Hard Against the Clock 154 8 Approximation Algorithms 156 6.8.1 Approximating Vertex Cover 157 6.8.2 The Euclidean Traveling Salesman 158 9 Exercises 160 7 How to Design Algorithms 163 II RESOURCES 8 A Catalog of Algorithmic Problems 171 1 Data Structures 174 8.1.1 Dictionaries 175 8.1.2 Priority Queues 180 8.1.3 Suffix Trees and Arrays 183 8.1.4 Graph Data Structures 187 8.1.5 Set Data Structures 191 8.1.6 Kd-Trees 194 2 Numerical Problems 197 8.2.1 Solving Linear Equations 199 8.2.2 Bandwidth Reduction 202 8.2.3 Matrix Multiplication 204 8.2.4 Determinants and Permanents 207 8.2.5 Constrained and Unconstrained Optimization 209 8.2.6 Linear Programming 213 8.2.7 Random Number Generation 217 8.2.8 Factoring and Primality Testing 221 8.2.9 Arbitrary-Precision Arithmetic 224 8.2.10 Knapsack Problem 228 8.2.11 Discrete Fourier Transform 232 3 Combinatorial Problems 235 8.3.1 Sorting 236 8.3.2 Searching 240 8.3.3 Median and Selection 244 8.3.4 Generating Permutations 246 8.3.5 Generating Subsets 250 8.3.6 Generating Partitions 253 8.3.7 Generating Graphs 257 8.3.8 Calendrical Calculations 261 8.3.9 fob Scheduling 263 8.3.10 Satisfiability 266

Contents xv 8.4 Graph 8.4.1 8.4.2 8.4.3 8.4.4 8.4.5 8.4.6 8.4.7 8.4.8 8.4.9 8.4.10 8.4.11 8.4.12 8.5 Graph 8.5.1 8.5.2 8.5.3 8.5.4 8.5.5 8.5.6 8.5.7 8.5.8 8.5.9 8.5.10 8.5.11 Problems: Polynomial-Time Connected Components Topological Sorting Minimum Spanning Tree Shortest Path Transitive Closure and Reduction Matching Eulerian Cycle / Chinese Postman Edge and Vertex Connectivity Network Flow Drawing Graphs Nicely Drawing Trees Planarity Detection and Embedding Problems: Hard Problems Clique Independent Set Vertex Cover Traveling Salesman Problem Hamiltonian Cycle Graph Partition Vertex Coloring Edge Coloring Graph Isomorphism Steiner Tree Feedback Edge/Vertex Set 8.6 Computational Geometry 8.6.1 Robust Geometric Primitives 8.6.2 Convex Hull 8.6.3 Triangulation 8.6.4 Voronoi Diagrams 8.6.5 Nearest Neighbor Search 8.6.6 Range Search 8.6.7 Point Location 8.6.8 Intersection Detection 8.6.9 Bin Packing 8.6.10 Medial-Axis Transformation 8.6.11 Polygon Partitioning 8.6.12 Simplifying Polygons 8.6.13 Shape Similarity 8.6.14 Motion Planning 8.6.15 Maintaining Line Arrangements 8.6.16 Minkowski Sum 8.7 Set and String Problems 8.7.1 8.7.2 Set Cover Set Packing 269 270 273 275 279 284 287 291 294 297 301 305 308 311 312 315 317 319 323 326 329 333 335 339 343 345 347 351 355 358 361 364 367 370 374 377 380 383 386 389 392 395 397 398 401

8.7.3 String Matching 403 8.7.4 Approximate String Matching 406 8.7.5 Text Compression 410 8.7.6 Cryptography 414 8.7.7 Finite State Machine Minimization 418 8.7.8 Longest Common Substring 422 8.7.9 Shortest Common Superstring 425 9 Algorithmic Resources 427 9.1 Software Systems 427 9.1.1 LEDA 428 9.1.2 Netlib 428 9.1.3 The Stanford GraphBase 429 9.1.4 Combinatorica 430 9.1.5 Algorithm Animations with XTango 430 9.1.6 Programs from Books 431 9.2 Data Sources 433 9.3 Textbooks 434 9.4 On-Line Resources 435 9.4.1 Literature 436 9.4.2 People 436 9.4.3 Software 437 9.5 Professional Consulting Services 437 Bibliography 439 Index 463