Understanding Time Complexity in Sorting Algorithms
Classified in Computers
Written at on English with a size of 12.09 KB.
1. What is recurrence for worst case of QuickSort and what is the time complexity in Worst case? Recurrence is T(n) = T(n-1) + O(n) and time complexity is O(n^2) 2. Suppose we have a O(n) time algorithm that finds median of an unsorted array. Now consider a QuickSort implementation where we first find median using the above algorithm, then use median as pivot. What will be the worst case time complexity of this modified QuickSort. O(nLogn) 3. Given an unsorted array. The array has this property that every element in array is at most k distance from its position in sorted array where k is a positive integer smaller than size of array. Which sorting algorithm can be easily modified for sorting this array and what is the obtainable time complexity?
... Continue reading "Understanding Time Complexity in Sorting Algorithms" »