Ask Question
18 October, 13:55

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.

+4
Answers (1)
  1. 18 October, 15:00
    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?
Get 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 there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers