[Solved] Can any one help me out in sorting the array by inserting k new elements


I have a new answer like as follows

  1. Sort the K new elements with merge sort which takes O(K * Log K)
  2. Now merge the two sorted arrays (Use Third Array, after finishing remove first and second arrays). The first array is already sorted which contains N elements and the second array contains K elements which in turn takes O(N + K) which is going to be O(N).

  3. So, the total time complexity is going to be O(K * Log K) (First Step) + O(N) (Second Step)

  4. Total time complexity is O( K * Log K + N)

3

solved Can any one help me out in sorting the array by inserting k new elements