Ask Question
4 May, 04:27

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.

+5
Answers (1)
  1. 4 May, 06:17
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers