Lower Bound on comparison based sorting is O (n log n) Merge sort and Heap sort have running time as O(n logn) and are considered to be among the best comparison sorting methods.
Lower Bound on comparison based sorting is O (n log n) Merge sort and Heap sort have running time as O(n logn) and are considered to be among the best comparison sorting methods.
Lower Bound on comparison based sorting is O (n log n) Merge sort and Heap sort have running time as O(n logn) and are considered to be among the best comparison sorting methods.
Many Sorting Methods Quick sort, Merge sort, Insertion sort, Bubble sort, Selection sort, Heap sort Merge sort and Heap sort have running time as (n log n) and are considered to be among the best comparison based sorting methods Can we sort in less than n log n time?
CS 306 DAA,IIITDM Jabalpur
10/16/2012
Lower Bound on Sorting
Claim: Any comparison sorting algorithm will requires at least (n log n) comparisons to sort n distinct items
Sorting Three Numbers
CS 306 DAA,IIITDM Jabalpur
10/16/2012
Sorting Three Numbers
Some Observations It required !3 number of leaf nodes one for each possible permutation of the three numbers The decision tree is a binary tree and the height of the tree is the worst case is 3 (the maximum number of comparisons along a path in the tree)
Sorting Three Numbers
Question: What can be the height of the decision tree of the cleverest algorithm? Ans: As low as possible (A nearly balance binary tree)
CS 306 DAA,IIITDM Jabalpur
10/16/2012
Lower Bound on Sorting
Lets assume the height of the binary tree as h No of leaves at level h = 2h Hence !n <= 2h h >= log (!n) h >= log (n*(n-1)*(n-2)*(n-3)* *3*2*1) h >= logn+ log (n-1)+ log (n-2)+ +log 3+ log 2+ log 1) h >= (n/2) log (n/2) = (n log n)
Lower Bound on Sorting
Hence Lower Bound on comparison based sorting is (n log n)