Consider the problem of sorting n elements. Any generalized sorting algorithm takes these n numbers and peforms comparisons to sort the numbers. The complexity of the algorithm is measured by the number of comparisons required. Note that the trace of the comparisons help one to trace back from the sorted array to the initial array of numbers. That is the comparison traces have the same information as the initial unsorted array. Based on the above idea, conclude that the sorting of n elements cannot be done better than O(nlogn) complexity. Hint: One comparison provides at most one bit of information of the initial sorted array, since you know the relative ordering of two numbers in the unsorted array
#Sales Offer!| Get upto 25% Off: