{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Bitonic sort merge is not stable bitonic merge sort

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: else r[k] ← tmp[i++]; 16 ! Bitonic-sort merge is not stable Bitonic! Merge Sort: improvements ! By By alternating the role of the output array and the auxiliary buffer (and proper initialization), we can avoid the the memcpy operations mergesort(tmp, r, lb, mid); mergesort(tmp, r, mid+1, ub); merge(r, tmp, lb, mid, ub); ! In-place merge sort by Katajainen, place Pasanen, Pasanen, and Teuhola, 1996 – High overhead to be practical 17 Time Time-Complexity Summary Algorithms Best Average Worst Linear Insertion O(n) O(n2) O(n2) Bubble O(n2) O(n2) O(n2) Quick O(n log n) log O(n log n) log O(n2) Straight Selection O(n2) O(n2) O(n2) Heap O(n log n) log O(n log n) log O(n log n) log Merge O(n log n) log O(n log n) log O(n log n) log 18 2) O( O(n ! vs. O(n log n) How can mergesort, quicksort, and heapsort achieve O(n log n) when insertion sort and bubble sort run at O(n2)? – Mergesort, quicksort, and heapsort move elements far distances, distances, correcting multiple inversions at a time – Insertion and bubble sort correct one inversion at a time ! Why is quicksort worst-case O(n2) while mergesort has no such problem? – The choice of pivot determines size of partitions, whereas mergesort cuts array in half every iteration – Selection sort uses the worst pivot in every itera...
View Full Document

{[ snackBarMessage ]}