{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

cse220sol6

# Show that any comparison based sorting needs at least

This preview shows pages 2–3. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

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

Unformatted text preview: Show that any comparison based sorting needs at least ( nlogk ) operations. (It is not rigorous enough to combine the lower bounds for the individual subsequences. ). Solution: In order to sort the sequence of n elements, the algorithm must sort the k elements in each of the n=k subsequences. Using one of the comparison-based sorting algorithms that you already know, this step will take O ( k log k ) time in the worst case (i.e heapsort, mergesort) or in average 2 case (i.e Quicksort). This is done for all n=k subsequences, so total time is O ( n log k ). In order to prove the lower bound we have to consider a decision tree. There are k ! permutations for each subsequence. The number of possible choices for all n=k subsequences is ( k !) n=k . The rst subsequence has k ! choices times the k ! choices of the second subsequence etc. This number of choices represents the number of leaves in the decision tree. The height of this decision tree is: h log( k !) n=k ( n=k ) log k ! (1) We know that log k ! = ( k log k ) (2). Combining relations (1), (2) ) : h = ( n log k ) Since the worst case of comparisons corresponds to the height of its decision tree, a lower bound on the height of the decision tree is a lower bound on the running time of any comparison based sorting. QED 3...
View Full Document

{[ snackBarMessage ]}

### Page2 / 3

Show that any comparison based sorting needs at least nlogk...

This preview shows document pages 2 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online