Algorithms: Richard Johnsonbaugh Marcus Schaefer
Algorithms: Richard Johnsonbaugh Marcus Schaefer
Richard Johnsonbaugh
Marcus Schaefer
DEPAUL UNIVERSITY
PEARSON
Prentice
Hall
Pearson Education
Upper Saddle River, New Jersey 07458
Contents
Preface ix
1 Introduction 1
1.1 Algorithms 1
1.2 Pseudocode for Algorithms 4
1.3 The Present 10
1.4 The Future 12
Notes 14
Chapter Exercises 14
3 Data Structures 99
3.1 Abstract Data Types 99
3.2 Stacks and Queues 101
3.3 Linked Lists 111
3.4 Binary Trees 120
3.5 Priority Queues, Binary Heaps, and Heapsort 133
3.6 Disjoint Sets 150
Notes 162
Chapter Exercises 162
VI Contents
4 Searching 165
4.1 Binary Search 165
4.2 Depth-First Search 172
4.3 Breadth-First Search 181
4.4 Topological Sort 188
4.5 Backtracking 195
Notes 209
Chapter Exercises 209
10 PandNP 429
10.1 Polynomial Time 429
10.2 Nondeterministic Algorithms and NP 437
10.3 Reducibility and NP-Completeness 452
10.4 NP-Complete Problems 466
10.5 More on NP-Completeness 474
Notes 481
Chapter Exercises 482
References 645
Index 735