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?
- Insertion Sort with time complexity O(kn)
- Quick Sort with time complexity O(kLogk)
- Heap Sort with time complexity O(nLogk)
- Merge Sort with time complexity O(nLogk)
Correct Answer:
Heap Sort with time complexity O(nLogk)
need an explanation for this answer? contact us directly to get an explanation for this answer