Download presentation
Presentation is loading. Please wait.
1
Lecture 31 CSE 331 Nov 12, 2010
2
HW 8 due today I will not take any HW after 1:15pm
Q1 in one pile and Q 2 in another I will not take any HW after 1:15pm
3
Graded HW 7 Individual pickups Atri: Fri office hours
Jeff: Recitations and Wed office hours Alex: Tuesday and Thursday office hours
4
HW 9 Posted on the webpage/blog
5
Mergesort algorithm Input: a1, a2, …, an
Output: Numbers in sorted order MergeSort( a, n ) If n = 1 return the order a1 aL = a1,…, a[n/2] aR = a[n/2]+1,…, an return MERGE ( MergeSort(aL, [n/2]), MergeSort(aR, n-[n/2]) ) If n = 2 return the order min(a1,a2); max(a1,a2)
6
Inductive step follows from correctness of MERGE
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
HW 8 due today I will not take any HW after 1:15pm
Q1 in one pile and Q 2 in another I will not take any HW after 1:15pm
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.