Ask Question

Given an array A of n + m elements. It is know that the first n elements in A are sorted and the last m elements in A are unsorted. Suggest an algorithm (only pseudo code) to sort A in O (mlogm + n) worst case running time complexity. Justify.

+3
Answers (1)
  1. 26 July, 04:04
    0
    We can divide array A into two arrays B, C

    B would contain the sorted n elements.

    C would contain the unsorted m elements.

    Now we can sort C using merge sort with worst time complexity mlogm.

    When you will have array C sorted you can concatenate with B and put it back in A.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Given an array A of n + m elements. It is know that the first n elements in A are sorted and the last m elements in A are unsorted. Suggest ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers