Chapter 1

from Introduction to Algorithms by Cormen


Document last modified: 

OVERVIEW

Some key topics covered in course

  1. Correctness - algorithm produces post conditions given pre conditions hold.
     
  2. Verification - proving formally or informally, that algorithm is correct.
     
  3. Analysis - determining the efficiency of an algorithm by formal methods or empirically (e.g. profiling).
     
  4. Algorithm methods - examine fundamental methods for algorithms, such as back-tracking, divide-and-conquer, search, etc.

 

Algorithm - any well-defined computational procedure that takes some value, or set of values, as input and produces some value, or set of values, as output

Some celebrity algorithms

Why study algorithms?

Important definitions

Useful thoughts


1.2 Algorithms as a technology

Efficiency

Linear search

Binary search

Comparison of some common complexity measures

n

n2

n3

2n

lg n

v n

n lg n

n!

1

1

1

2

 0

1

0

1

2

4

8

4

1

1

2

2

3

9

27

8

2

2

5

6

4

16

64

16

2

2

8

24

5

25

125

32

2

2

12

120

6

36

216

64

3

2

16

720

7

49

343

128

3

3

20

5,040

8

64

512

256

3

3

24

40,320

9

81

729

512

3

3

29

362,880

10

100

1,000

1,024

3

3

33

3,628,800

11

121

1,331

2,048

3

3

38

39,916,800

12

144

1,728

4,096

4

3

43

479,001,600

13

169

2,197

8,192

4

4

48

6,227,020,800

14

196

2,744

16,384

4

4

53

87,178,291,200

15

225

3,375

32,768

4

4

59

1,307,674,368,000

16

256

4,096

65,536

4

4

64

20,922,789,888,000

17

289

4,913

131,072

4

4

69

355,687,428,096,000

18

324

5,832

262,144

4

4

75

6,402,373,705,728,000

19

361

6,859

524,288

4

4

81

121,645,100,408,832,000

20

400

8,000

1,048,576

4

4

86

2,432,902,008,176,640,000

21

441

9,261

2,097,152

4

5

92

51,090,942,171,709,400,000

22

484

10,648

4,194,304

4

5

98

1,124,000,727,777,610,000,000

23

529

12,167

8,388,608

5

5

104

25,852,016,738,885,000,000,000

24

576

13,824

16,777,216

5

5

110

620,448,401,733,239,000,000,000

25

625

15,625

33,554,432

5

5

116

15,511,210,043,331,000,000,000,000

26

676

17,576

67,108,864

5

5

122

403,291,461,126,606,000,000,000,000

27

729

19,683

134,217,728

5

5

128

10,888,869,450,418,400,000,000,000,000

28

784

21,952

268,435,456

5

5

135

304,888,344,611,714,000,000,000,000,000

29

841

24,389

536,870,912

5

5

141

8,841,761,993,739,700,000,000,000,000,000

30

900

27,000

1,073,741,824

5

5

147

265,252,859,812,191,000,000,000,000,000,000

Question 1.1

For a function f(n) determine the largest problem size n that can be solved in time t, assuming that the algorithm to solve the problem takes f(n) microseconds.

Note for functions with inverses, such as:

f(n) = v n = 1,000,000 ms, the inverse v n 2 = n = 1,000,0002 =(106)2 = 1012

f(n) = log2n = lg n = 1,000,000 ms, the inverse 2lg n = n = 21,000,000

f(n) t = 1 sec. = 106 ms t = 1 min. = 6*107 ms
n   6*107
lg n 21,000,000  
n! 9 from above table