Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 28 CSE 331 Nov 9, 2015. Mini project report due WED.

Similar presentations


Presentation on theme: "Lecture 28 CSE 331 Nov 9, 2015. Mini project report due WED."— Presentation transcript:

1 Lecture 28 CSE 331 Nov 9, 2015

2 Mini project report due WED

3 Piazza Participation Cutoffs

4 Mergesort algorithm Input: a 1, a 2, …, a n Output: Numbers in sorted order MergeSort( a, n ) a L = a 1,…, a n/2 a R = a n/2+1,…, a n return MERGE ( MergeSort(a L, n/2), MergeSort(a R, n/2) ) If n = 1 return the order a 1

5 Correctness Input: a 1, a 2, …, a n Output: Numbers in sorted order MergeSort( a, n ) a L = a 1,…, a n/2 a R = a n/2+1,…, a n return MERGE ( MergeSort(a L, n/2), MergeSort(a R, n/2) ) By induction on n Inductive step follows from correctness of MERGE If n = 1 return the order a 1

6 Rest of today’s agenda Analyze runtime of mergesort algorithm

7 Divide and Conquer Divide up the problem into at least two sub-problems Recursively solve the sub-problems “Patch up” the solutions to the sub-problems for the final solution

8 Improvements on a smaller scale Greedy algorithms: exponential  poly time (Typical) Divide and Conquer: O(n 2 )  asymptotically smaller running time

9 Multiplying two numbers Given two numbers a and b in binary a=(a n-1,..,a 0 ) and b = (b n-1,…,b 0 ) Compute c = a x b Running time of primary school algorithm?


Download ppt "Lecture 28 CSE 331 Nov 9, 2015. Mini project report due WED."

Similar presentations


Ads by Google