This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: divide this into two sets >>mergeSort(3,8,15,19) and mergeSort(23,6,1,10) divide again >>mergeSort(3,8), mergeSort(15,19), mergeSort(23,6), mergeSort(1,10) divide again ...ms(3), ms(8),. ..... put two together s=(3,8) s=(15,19) s=(6,23) s=(1,10) again s=(3,8,15,19) s=(1,6,10,23) again s=(1,3,6,8,10,15,19,23) How long does merge sort take? To find this out, we use sth called amortized time, that is we find first the time spent in one element in the array and then multiply this by n (the number of elements) Instructions done for one element:copy operations: the # of comparisons is also the # of times an elementcomparison:nlog(n) is copied to the new array, in the merge step If there are n elements, the time will be O(nlog(n))...
View
Full
Document
This note was uploaded on 02/04/2012 for the course CS 251 taught by Professor Staff during the Fall '08 term at Purdue UniversityWest Lafayette.
 Fall '08
 Staff
 Algorithms, Sort, Bubble Sort

Click to edit the document details