Read without ads and support Scribd by becoming a Scribd Premium Reader.
Algorithms
Copyrightc
\ue0002006 S. Dasgupta, C. H. Papadimitriou, and U. V. Vazirani
May 22, 2006
2
Contents
Preface
7
0 Prologue
9

0.1 Books and algorithms. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 0.2 EnterFibonacci. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 0.3 Big-O notation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 Exercises. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

1 Algorithms with numbers
19

1.1 Basicarithmetic. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 1.2 Modulararithmetic. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 1.3 Primalitytesting. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 1.4 Cryptography. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 1.5 Universalhashing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 Exercises. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

2 Divide-and-conqueralgorithms
49

2.1 Multiplication. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 2.2 Recurrencerelations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 2.3 Mergesort. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 2.4 Medians. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 2.5 Matrixmultiplication. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 2.6 The fast Fourier transform. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 Exercises. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75

3 Decompositions of graphs
83

3.1 Whygraphs?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 3.2 Depth-\ufb01rst search in undirected graphs. . . . . . . . . . . . . . . . . . . . . . . . 85 3.3 Depth-\ufb01rst search in directed graphs. . . . . . . . . . . . . . . . . . . . . . . . . . 90 3.4 Strongly connected components. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 Exercises. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97

4 Paths in graphs
105

4.1 Distances. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 4.2 Breadth-\ufb01rstsearch. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 4.3 Lengths on edges. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108

3
Search History:
Searching...
Result 00 of 00
00 results for result for
  • p.
  • Notes
    Load more