Presentation is loading. Please wait.

Presentation is loading. Please wait.

Instructor: Shengyu Zhang 1. Example 1: Merge sort 2.

Similar presentations


Presentation on theme: "Instructor: Shengyu Zhang 1. Example 1: Merge sort 2."— Presentation transcript:

1 Instructor: Shengyu Zhang 1

2 Example 1: Merge sort 2

3 Starting example 3

4 An algorithm: merge sort 4

5 Complexity? 5

6 How to solve/bound this recurrence relation? 6

7 A general method for designing algorithm: Divide and conquer Breaking the problem into subproblems  that are themselves smaller instances of the same type of problem Recursively solving these subproblems Appropriately combining their answers 7

8 Complexity 8

9 Master theorem 9

10 10

11 Example 2: Selection 11

12 Selection 12

13 Idea of divide and conquer 13

14 Pivot 14

15 After the partition 15

16 Divide and conquer 16

17 17

18 18

19 19

20 20

21 21

22 Example 3: Matrix multiplication 22

23 Matrix multiplication 23

24 24

25 25

26 26

27 27

28 God knows how he came up with it. And here is how: where 28

29 29

30 30

31 Fast Fourier Transform (FFT) 31

32 Multiplication of polynomials 32

33 Multiplication 33

34 Better? YES! 34

35 What determines/represents a polynomial? 35

36 Reason 36

37 unknowns 37

38 Advantage of point-value representation? 38

39 Go to an easy world and come back HK used to have many industries. Later found mainland has less expensive labor. So:  moved the companies to mainland,  did the work there,  and then shipped the products back to HK to sell This is worth doing if: it’s cheaper in mainland, and the traveling/shipping is not expensive either.  which turned out to be true. 39

40 In our case We need to investigate: the cost of traveling.  Both way. 40

41 Traveling 41

42 Evaluation 42

43 Number of points 43

44 44

45 Complex roots of unity

46 All the essences are here… 46

47 Distinct points 47

48 48

49 Interpolation 49

50 50

51 51

52 Or 52

53 Summary Divide and conquer is a general method to design algorithms. Master theorem to compute the complexity. Several examples.  Merge sort  Selection  Matrix multiplication  FFT 53


Download ppt "Instructor: Shengyu Zhang 1. Example 1: Merge sort 2."

Similar presentations


Ads by Google