1 / 8

Understanding MergeSort Algorithm: Lecture Summary and Homework Reminder

In this lecture, we explore the MergeSort algorithm, which sorts a given array of numbers in O(n log n) time. The input is an unsorted array, and the output is the array in sorted order. We'll discuss the base case for two elements, the recursive division of the array into left and right halves (aL and aR), and the merging process. Additionally, important reminders include submitting homework by 1:10 PM on Fridays and attending extra question sessions next week. Get ready to solve recurrences and delve deeper into the efficiency of MergeSort!

maitland
Download Presentation

Understanding MergeSort Algorithm: Lecture Summary and Homework Reminder

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 29 CSE 331 Nov 11, 2009

  2. To be strictly enforced For the rest of the semester on Fridays SUBMIT your HOMEWORKS by 1:10 PM

  3. Extra Q sessions next week Monday and Tuesday 4-6pm CSE 242

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

  5. An example run 1 51 51 1 19 100 100 19 2 2 8 8 4 3 3 4 1 8 1 2 19 19 3 2 4 51 51 3 100 4 8 100 MergeSort( a, n ) If n = 2 return the order min(a1,a2); max(a1,a2) aL = a1,…, an/2 aR = an/2+1,…, an return MERGE ( MergeSort(aL, n/2), MergeSort(aR, n/2) )

  6. Correctness Input: a1, a2, …, an Output: Numbers in sorted order By induction on n MergeSort( a, n ) If n = 2 return the order min(a1,a2); max(a1,a2) 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

  7. Today’s agenda Show that Mergesort runs in O(n log n) time Solve recurrences

  8. To be strictly enforced For the rest of the semester on Fridays SUBMIT your HOMEWORKS by 1:10 PM

More Related