Back to the 2022 paper

Module 1: Introduction and Complexity Analysis

20222m

Given an unsorted array. The array has this property that every element in array is at most kk distance from its position in sorted array where kk 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?

  • (i) Insertion sort with time complexity O(kn)O(kn)
  • (ii) Heap sort with time complexity O(nlogk)O(n \log k)
  • (iii) Quick sort with time complexity O(klogk)O(k \log k)
  • (iv) Merge sort with time complexity O(klogk)O(k \log k)

Similar questions