1 / 11

Lecture 28

Lecture 28. CSE 331 Nov 3, 2014. Mini project report due WED. Mini Project Report. Response to Feedback. Oct Piazza Participation Report. Mergesort algorithm. Input: a 1 , a 2 , …, a n. Output: Numbers in sorted order. MergeSort ( a, n ). If n = 1 return the order a 1.

aileenc
Download Presentation

Lecture 28

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture 28 CSE 331 Nov 3, 2014

  2. Mini project report due WED

  3. Mini Project Report

  4. Response to Feedback

  5. Oct Piazza Participation Report

  6. Mergesort algorithm Input: a1, a2, …, an Output: Numbers in sorted order MergeSort( a, n ) If n = 1 return the order a1 aL = a1,…, an/2 aR = an/2+1,…, an return MERGE ( MergeSort(aL, n/2), MergeSort(aR, n/2) )

  7. Correctness Input: a1, a2, …, an Output: Numbers in sorted order By induction on n MergeSort( a, n ) If n = 1 return the order a1 aL = a1,…, an/2 aR = an/2+1,…, an return MERGE ( MergeSort(aL, n/2), MergeSort(aR, n/2) ) Inductive step follows from correctness of MERGE

  8. Rest of today’s agenda Analyze runtime of mergesort algorithm

  9. 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

  10. Improvements on a smaller scale Greedy algorithms: exponential  poly time (Typical) Divide and Conquer: O(n2)  asymptotically smaller running time

  11. Multiplying two numbers Given two numbers a and b in binary a=(an-1,..,a0) and b = (bn-1,…,b0) Running time of primary school algorithm? Compute c = a x b

More Related