T H O M A S H. C O R M E N
C H A R L E S E. L
E I S E R S O N
R O N A L D L . R I V E S T
C L I F F O R D S T E I N
I N T R O D U C T I O N T O
A L G O R I T H M S
T H I R D E D I T I O N
Introduction to Algorithms
Third Edition
Thomas H. Cormen
Charles E. Leiserson
Ronald L. Rivest
Clifford Stein
Introduction to Algorithms
Third EditionThe MIT Press
Cambridge, Massachusetts
London, England
c 2009 Massachusetts Institute of Technology
All rights reserved. No part of this book may be reproduced in any form or by any electronic or mechanical means
(including photocopying, recording, or information storage and retrieval) without permission in writing from the
publisher.
For information about special quantity discounts, please email special sales@mitpress.mit.edu.
This book was set in Times Roman and Mathtime Pro 2 by the authors.
Printed and bound in the United States of America.
Library of Congress Cataloging-in-Publication Data
Introduction to algorithms / Thomas H. Cormen . . . [et al.].--3rd ed.
p. cm.
Includes bibliographical references and index.
ISBN 978-0-262-03384-8 (hardcover : alk. paper)--ISBN 978-0-262-53305-8 (pbk. : alk. paper)
1. Computer programming.
2. Computer algorithms. I. Cormen, Thomas H.
QA76.6.I5858 2009
005.1--dc22
2009008593
10 9 8 7 6 5 4 3 2
Contents
PrefacexiiiIFoundationsIntroduction31The Role of Algorithms in Computing51.1
Algorithms
51.2
Algorithms as a technology
112Getting Started162.1
Insertion sort
162.2
Analyzing algorithms
232.3
Designing algorithms
293Growth of Functions433.1
Asymptotic notation
433.2
Standard notations and common functions
534Divide-and-Conquer654.1
The maximum-subarray problem
684.2
Strassen's algorithm for matrix multiplication
754.3
The substitution method for solving recurrences
834.4
The recursion-tree method for solving recurrences
884.5
The master method for solving recurrences
93?
4.6
Proof of the master theorem
975Probabilistic Analysis and Randomized Algorithms1145.1
The hiring problem
1145.2
Indicator random variables
1185.3
Randomized algorithms
122?
5.4
Probabilistic analysis and further uses of indicator random variables
130
viContentsIISorting and Order StatisticsIntroduction1476Heapsort1516.1
Heaps
1516.2
Maintaining the heap property
1546.3
Building a heap
1566.4
The heapsort algorithm
1596.5
Priority queues
1627Quicksort1707.1
Description of quicksort
1707.2
Performance of quicksort
1747.3
A randomized version of quicksort
1797.4
Analysis of quicksort
1808Sorting in Linear Time1918.1
Lower bounds for sorting
1918.2
Counting sort
1948.3
Radix sort
1978.4
Bucket sort
2009Medians and Order Statistics2139.1
Minimum and maximum
2149.2
Selection in expected linear time
2159.3
Selection in worst-case linear time
220IIIData StructuresIntroduction22910Elementary Data Structures23210.1 Stacks and queues
23210.2 Linked lists
23610.3 Implementing pointers and objects
24110.4 Representing rooted trees
24611Hash Tables25311.1 Direct-address tables
25411.2 Hash tables
25611.3 Hash functions
26211.4 Open addressing
269?
11.5 Perfect hashing
277
Contentsvii12Binary Search Trees28612.1 What is a binary search tree?
28612.2 Querying a binary search tree
28912.3 Insertion and deletion
294?
12.4 Randomly built binary search trees
29913Red-Black Trees30813.1 Properties of red-black trees
30813.2 Rotations
31213.3 Insertion
31513.4 Deletion
32314Augmenting Data Structures33914.1 Dynamic order statistics
33914.2 How to augment a data structure
34514.3 Interval trees
348IVAdvanced Design and Analysis TechniquesIntroduction35715Dynamic Programming35915.1 Rod cutting
36015.2 Matrix-chain multiplication
37015.3 Elements of dynamic programming
37815.4 Longest common subsequence
39015.5 Optimal binary search trees
39716Greedy Algorithms41416.1 An activity-selection problem
41516.2 Elements of the greedy strategy
42316.3 Huffman codes
428?
16.4 Matroids and greedy methods
437?
16.5 A task-scheduling problem as a matroid
44317Amortized Analysis45117.1 Aggregate analysis
45217.2 The accounting method
45617.3 The potential method
45917.4 Dynamic tables
463
viiiContentsVAdvanced Data StructuresIntroduction48118B-Trees48418.1 Definition of B-trees
48818.2 Basic operations on B-trees
49118.3 Deleting a key from a B-tree
49919Fibonacci Heaps50519.1 Structure of Fibonacci heaps
50719.2 Mergeable-heap operations
51019.3 Decreasing a key and deleting a node
51819.4 Bounding the maximum degree
52320van Emde Boas Trees53120.1 Preliminary approaches
53220.2 A recursive structure
53620.3 The van Emde Boas tree
54521Data Structures for Disjoint Sets56121.1 Disjoint-set operations
56121.2 Linked-list representation of disjoint sets
56421.3 Disjoint-set forests
568?
21.4 Analysis of union by rank with path compression
573VIGraph AlgorithmsIntroduction58722Elementary Graph Algorithms58922.1 Representations of graphs
58922.2 Breadth-first search
59422.3 Depth-first search
60322.4 Topological sort
61222.5 Strongly connected components
61523Minimum Spanning Trees62423.1 Growing a minimum spanning tree
62523.2 The algorithms of Kruskal and Prim
631
Contentsix24Single-Source Shortest Paths64324.1 The Bellman-Ford algorithm
65124.2 Single-source shortest paths in directed acyclic graphs
65524.3 Dijkstra's algorithm
65824.4 Difference constraints and shortest paths
66424.5 Proofs of shortest-paths properties
67125All-Pairs Shortest Paths68425.1 Shortest paths and matrix multiplication
68625.2 The Floyd-Warshall algorithm
69325.3 Johnson's algorithm for sparse graphs
70026Maximum Flow70826.1 Flow networks
70926.2 The Ford-Fulkerson method
71426.3 Maximum bipartite matching
732?
26.4 Push-relabel algorithms
736?
26.5 The relabel-to-front algorithm
748VIISelected TopicsIntroduction76927Multithreaded Algorithms77227.1 The basics of dynamic multithreading
77427.2 Multithreaded matrix multiplication
79227.3 Multithreaded merge sort
79728Matrix Operations81328.1 Solving systems of linear equations
81328.2 Inverting matrices
82728.3 Symmetric positive-definite matrices and least-squares approximation
83229Linear Programming84329.1 Standard and slack forms
85029.2 Formulating problems as linear programs
85929.3 The simplex algorithm
86429.4 Duality
87929.5 The initial basic feasible solution
886
Document Outline
- Contents
- Preface
- I Foundations
- 1 The Role of Algorithms in Computing
- 2 Getting Started
- 3 Growth of Functions
- 4 Divide-and-Conquer
- 5 Probabilistic Analysis and Randomized Algorithms
- II Sorting and Order Statistics
- 6 Heapsort
- 7 Quicksort
- 8 Sorting in Linear Time
- 9 Medians and Order Statistics
- III Data Structures
- 10 Elementary Data Structures
- 11 Hash Tables
- 12 Binary Search Trees
- 13 Red-Black Trees
- 14 Augmenting Data Structures
- IV Advanced Design and Analysis Techniques
- 15 Dynamic Programming
- 16 Greedy Algorithms
- 17 Amortized Analysis
- V Advanced Data Structures
- 18 B-Trees
- 19 Fibonacci Heaps
- 20 van Emde Boas Trees
- 21 Data Structures for Disjoint Sets
- VI Graph Algorithms
- 22 Elementary Graph Algorithms
- 23 Minimum Spanning Trees
- 24 Single-Source Shortest Paths
- 25 All-Pairs Shortest Paths
- 26 Maximum Flow
- VII Selected Topics
- 27 Multithreaded Algorithms
- 28 Matrix Operations
- 29 Linear Programming
- 30 Polynomials and the FFT
- 31 Number-Theoretic Algorithms
- 32 String Matching
- 33 Computational Geometry
- 34 NP-Completeness
- 35 Approximation Algorithms
- VIII Appendix: Mathematical Background
- A Summations
- B Sets, Etc.
- C Counting and Probability
- D Matrices
- Bibliography
- Index
Add New Comment