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

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

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

Lecture 1. Introduction

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

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

Introduction to Algorithms Third Edition

5105 BHARATHIDASAN ENGINEERING COLLEGE

DESIGN AND ANALYSIS OF ALGORITHMS

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

DATA ABSTRACTION AND PROBLEM SOLVING WITH JAVA

Topic Analysis PART-A

Analysis of Algorithms

DESIGN AND ANALYSIS OF ALGORITHMS

Virtual University of Pakistan

CLASSIC DATA STRUCTURES IN JAVA

Database Concepts. David M. Kroenke UNIVERSITATSBIBLIOTHEK HANNOVER

Prelude to Programming

CS6402 DESIGN AND ANALYSIS OF ALGORITHMS QUESTION BANK UNIT I

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

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

15CS43: DESIGN AND ANALYSIS OF ALGORITHMS

ony Gaddis Haywood Community College STARTING OUT WITH PEARSON Amsterdam Cape Town Dubai London Madrid Milan Munich Paris Montreal Toronto

Data Structures and Algorithm Analysis in C++

DESIGN AND ANALYSIS OF ALGORITHMS

CS-6402 DESIGN AND ANALYSIS OF ALGORITHMS

The Algorithm Design Manual

LECTURE 3 ALGORITHM DESIGN PARADIGMS

PROBLEM SOLVING USING JAVA WITH DATA STRUCTURES. A Multimedia Approach. Mark Guzdial and Barbara Ericson PEARSON. College of Computing

Visual C# Tony Gaddis. Haywood Community College STARTING OUT WITH. Piyali Sengupta. Third Edition. Global Edition contributions by.

World Wide Web PROGRAMMING THE PEARSON EIGHTH EDITION. University of Colorado at Colorado Springs

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

Chapter 1 Introduction

Data Structures and Abstractions with Java

THE AVR MICROCONTROLLER AND EMBEDDED SYSTEMS. Using Assembly and С

Algorithm Design Paradigms

INSTITUTE OF AERONAUTICAL ENGINEERING

Programming in Python 3

DATA STRUCTURES AND PROBLEM SOLVING USING JAVA

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

MATHEMATICAL STRUCTURES FOR COMPUTER SCIENCE

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

Ph.D. Comprehensive Examination Design and Analysis of Algorithms

R13 SET - 1. ''' '' ''' ' blog: anilkumarprathipati.wordpress.com. Code No: RT32054

Essentials of Database Management

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

ECE250: Algorithms and Data Structures Final Review Course

CSC Design and Analysis of Algorithms. Lecture 5. Decrease and Conquer Algorithm Design Technique. Decrease-and-Conquer

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

END-TERM EXAMINATION

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

Business Driven Data Communications

Introductory Combinatorics

Data Structures and Abstractions with Java

Algorithm Analysis and Design

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

CSci 231 Final Review

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

AC64/AT64 DESIGN & ANALYSIS OF ALGORITHMS JUN 2015

Chapter 9 Graph Algorithms

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

Chapter 9 Graph Algorithms

Review for Midterm Exam

Chapter 9 Graph Algorithms

Course Review for Finals. Cpt S 223 Fall 2008

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

Algorithms Interview Questions

Integrated Approach. Operating Systems COMPUTER SYSTEMS. LEAHY, Jr. Georgia Institute of Technology. Umakishore RAMACHANDRAN. William D.

4. Give the diagram representation of Notion of algorithm. [M 13]

THE DESIGN AND ANALYSIS OF COMPUTER ALGORITHMS

Ph.D. Written Examination Syllabus

Systems:;-'./'--'.; r. Ramez Elmasri Department of Computer Science and Engineering The University of Texas at Arlington

Introductory logic and sets for Computer scientists

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

Review of course COMP-251B winter 2010

Data Structures in C++ Using the Standard Template Library

Algorithms and Data Structures CS-CO-412

( ) 1 B. 1. Suppose f x

«Computer Science» Requirements for applicants by Innopolis University

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

CRYPTOGRAPHY AND NETWORK SECURITY

DATA AND COMPUTER COMMUNICATIONS

CS 6402 DESIGN AND ANALYSIS OF ALGORITHMS QUESTION BANK

logn D. Θ C. Θ n 2 ( ) ( ) f n B. nlogn Ο n2 n 2 D. Ο & % ( C. Θ # ( D. Θ n ( ) Ω f ( n)

CS6402-DESIGN AND ANALYSIS OF ALGORITHM. TWO MARK QUESTION WITH ANSWERS Unit-I. Introduction

Algorithmic Graph Theory and Perfect Graphs

MACHINES AND MECHANISMS

CSC Design and Analysis of Algorithms

CSC 8301 Design and Analysis of Algorithms: Exhaustive Search

A 0 A 1... A i 1 A i,..., A min,..., A n 1 in their final positions the last n i elements After n 1 passes, the list is sorted.

CSC Design and Analysis of Algorithms. Lecture 7. Transform and Conquer I Algorithm Design Technique. Transform and Conquer

FUNDAMENTALS OF. Database S wctpmc. Shamkant B. Navathe College of Computing Georgia Institute of Technology. Addison-Wesley

PYTHON. p ykos vtawynivis. Second eciitiovl. CO Ve, WESLEY J. CHUN

Part I Basic Concepts 1

DISCRETE MATHEMATICS

COMP 251 Winter 2017 Online quizzes with answers

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

UCS-406 (Data Structure) Lab Assignment-1 (2 weeks)

Computational Discrete Mathematics


Lecture 7. Transform-and-Conquer

Transcription:

Introduction to TllG DCSISFI & mmmmm Analysis of Algorithms 3RD EDITION Anany Levitin Villa nova University International Edition contributions by Soumen Mukherjee RCC Institute of Information Technology Arup Kumar Bhattacharjee RCC Institute of Information Technology PEARSON Boston Columbus Indianapolis New York San Francisco Upper Saddle River Amsterdam CapeTown Dubai London Madrid Milan Munich Paris Montreal Toronto Delhi Mexico City Sao Paulo Sydney Hong Kong Seoul Singapore Taipei Tokyo

Contents New to the Third Edition 17 Preface 19 *f 1 Introduction 27 1.1 What Is an Algorithm? 29 Exercises 1.1 33 1.2 Fundamentals of Algorithmic Problem Solving 35 Understanding the Problem 35 Ascertaining the Capabilities of the Computational Device 35 Choosing between Exact and Approximate Problem Solving 37 Algorithm Design Techniques 37 Designing an Algorithm and Data Structures 38 Methods of Specifying an Algorithm 38 Proving an Algorithm's Correctness 39 Analyzing an Algorithm 40 Coding an Algorithm 41 Exercises 1.2 43 1.3 Important Problem Types 44 Sorting 45 Searching 46 String Processing 46 Graph Problems 47 Combinatorial Problems 47 Geometric Problems 48 Numerical Problems 48 Exercises 1.3 49 7

8 Contents 1.4 Fundamental Data Structures 51 Linear Data Structures 51 Graphs 54 Trees 57 Sets and Dictionaries 61 Exercises 1.4 63 Summary 64 2 Fundamentals of the Analysis of Algorithm Efficiency 67 2.1 The Analysis Framework 68 Measuring an Input's Size 69 Units for Measuring Running Time 70 Orders of Growth 71 Worst-Case, Best-Case, and Average-Case Efficiencies 73 Recapitulation of the Analysis Framework 76 Exercises 2.1 76 2.2 Asymptotic Notations and Basic Efficiency Classes 78 Informal Introduction 78 O-notation 79 Q-notation 80 -notation 81 Useful Property Involving the Asymptotic Notations 81 Using Limits for Comparing Orders of Growth 82 Basic Efficiency Classes 84 Exercises 2.2 84 2.3 Mathematical Analysis of Nonrecursive Algorithms 87 Exercises 2.3 93 2.4 Mathematical Analysis of Recursive Algorithms 96 Exercises 2.4 102 2.5 Example: Computing the nth Fibonacci Number 106 Exercises 2.5 109 2.6 Empirical Analysis of Algorithms 110 Exercises 2.6 115 2.7 Algorithm Visualization 117 Summary 120

Contents 9 *% O Brute Force and Exhaustive Search 123 3.1 Selection Sort and Bubble Sort 124 Selection Sort 124 Bubble Sort 126 Exercises 3.1 128 3.2 Sequential Search and Brute-Force String Matching 130 Sequential Search 130 Brute-Force String Matching 131 Exercises 3.2 132 3.3 Closest-Pair and Convex-Hull Problems by Brute Force 134 Closest-Pair Problem 134 Convex-Hull Problem 135 Exercises 3.3 139 3.4 Exhaustive Search 141 Traveling Salesman Problem 142 Knapsack Problem 142 Assignment Problem 145 Exercises 3.4 146 3.5 Depth-First Search and Breadth-First Search 148 Depth-First Search 148 Breadth-First Search 151 Exercises 3.5 154 Summary 156 4 Decrease-and-Conquer 157 4.1 Insertion Sort 160 Exercises 4.1 162 4.2 Topological Sorting 164 Exercises 4.2 168 4.3 Algorithms for Generating Combinatorial Objects 170 Generating Permutations 170 Generating Subsets 172 Exercises 4.3 174

10 Contents 4.4 Decrease-by-a-Constant-Factor Algorithms 176 Binary Search 176 Fake-Coin Problem 178 Russian Peasant Multiplication 179 Josephus Problem 180 Exercises 4.4 182 4.5 Variable-Size-Decrease Algorithms 183 Computing a Median and the Selection Problem 184 Interpolation Search 187 Searching and Insertion in a Binary Search Tree 189 The Game of Nim 190 Exercises 4.5 192 Summary 193 E S3 Divide-and-Conquer 195 5.1 Mergesort 198 Exercises 5.1 200 5.2 Quicksort 202 Exercises 5.2 207 5.3 Binary Tree Traversals and Related Properties 208 Exercises 5.3 211 5.4 Multiplication of Large Integers and Strassen's Matrix Multiplication 212 Multiplication of Large Integers 213 Strassen's Matrix Multiplication 215 Exercises 5.4 217 5.5 The Closest-Pair and Convex-Hull Problems by Divide-and-Conquer 218 The Closest-Pair Problem 218 Convex-Hull Problem 221 Exercises 5.5 223 Summary 224

Contents 11 jcl w Transform-and-Conquer 227 6.1 Presorting 228 Exercises 6.1 231 6.2 Gaussian Elimination 234 LU Decomposition 238 Computing a Matrix Inverse 240 Computing a Determinant 241 Exercises 6.2 242 6.3 Balanced Search Trees 244 AVL Trees 244 2-3 Trees 249 Exercises 6.3 251 6.4 Heaps and Heapsort 252 Notion of the Heap 253 Heapsort 257 Exercises 6.4 259 6.5 Horner's Rule and Binary Exponentiation 260 Horner's Rule 260 Binary Exponentiation 262 Exercises 6.5 265 6.6 Problem Reduction 266 Computing the Least Common Multiple 267 Counting Paths in a Graph 268 Reduction of Optimization Problems 269 Linear Programming 270 Reduction to Graph Problems 272 Exercises 6.6 274 Summary 276 «so / Space and Time Trade-Offs 279 7.1 Sorting by Counting 280 Exercises 7.1 283 7.2 Input Enhancement in String Matching 284 Horspool's Algorithm 285

12 Contents Boyer-Moore Algorithm 289 Exercises 7.2 293 7.3 Hashing 295 Open Hashing (Separate Chaining) 296 Closed Hashing (Open Addressing) 298 Exercises 7.3 300 7.4 B-Trees 302 Exercises 7.4 305 Summary 306 Q O Dynamic Programming 309 8.1 Three Basic Examples 311 Exercises 8.1 316 8.2 The Knapsack Problem and Memory Functions 318 Memory Functions 320 Exercises 8.2 322 8.3 Optimal Binary Search Trees 323 Exercises 8.3 329 8.4 Warshall's and Floyd's Algorithms 330 Warshall's Algorithm 330 Floyd's Algorithm for the All-Pairs Shortest-Paths Problem 334 Exercises 8.4 337 Summary 338 9 Greedy Technique 341 9.1 Prim's Algorithm 344 Exercises 9.1 348 9.2 Kruskal's Algorithm 351 Disjoint Subsets and Union-Find Algorithms 353 Exercises 9.2 357 9.3 Dijkstra's Algorithm 359 Exercises 9.3 363

Contents 13 9.4 Huffman Trees and Codes 364 Exercises 9.4 368 Summary 370 IO Iterative Improvement 371 10.1 The Simplex Method 372 Geometric Interpretation of Linear Programming 373 An Outline of the Simplex Method 377 Further Notes on the Simplex Method 383 Exercises 10.1 385 10.2 The Maximum-Flow Problem 387 Exercises 10.2 397 10.3 Maximum Matching in Bipartite Graphs 398 Exercises 10.3 404 10.4 The Stable Marriage Problem 406 Exercises 10.4 409 Summary 410 Iflf^sm I Limitations of Algorithm Power 413 11.1 Lower-Bound Arguments 414 Trivial Lower Bounds 415 Information-Theoretic Arguments 416 Adversary Arguments 416 Problem Reduction 417 Exercises 11.1 419 11.2 Decision Trees 420 Decision Trees for Sorting 421 Decision Trees for Searching a Sorted Array 423 Exercises 11.2 425 11.3 P, NP, and A/P-Complete Problems 427 P and NP Problems 428 A/P-Complete Problems 432 Exercises 11.3 435

14 Contents 11.4 Challenges of Numerical Algorithms 438 Exercises 11.4 445 Summary 446 1 2 Coping with the Limitations of Algorithm Power 449 12.1 Backtracking 450 n-queens Problem 451 Hamiltonian Circuit Problem 452 Subset-Sum Problem 453 General Remarks 454 Exercises 12.1 456 12.2 Branch-and-Bound 458 Assignment Problem 459 Knapsack Problem 462 Traveling Salesman Problem 464 Exercises 12.2 466 12.3 Approximation Algorithms for /VP-Hard Problems 467 Approximation Algorithms for the Traveling Salesman Problem 469 Approximation Algorithms for the Knapsack Problem 479 Exercises 12.3 483 12.4 Algorithms for Solving Nonlinear Equations 485 Bisection Method 486 Method of False Position 490 Newton's Method 490 Exercises 12.4 493 Summary 494 Epilogue 497 APPENDIX A Useful Formulas for the Analysis of Algorithms 501 Properties of Logarithms 501 Combinatorics 501 Important Summation Formulas 502 Sum Manipulation Rules 502

Contents 15 Approximation of a Sum by a Definite Integral 503 Floor and Ceiling Formulas 503 Miscellaneous 503 APPENDIX B Short Tutorial on Recurrence Relations 505 Sequences and Recurrence Relations 505 Methods for Solving Recurrence Relations 506 Common Recurrence Types in Algorithm Analysis 511 References 519 Hints to Exercises 529 Index 571