Consider a set G consisting of m integers.
Note: lg denote the logarithm base 2.
b) Design an algorithm that solves the above problem using a mandatory heap and has time complexity O(m + k*lg(m)) and space complexity O(m).
In response give either pseudocode or the description of the steps of the algorithm and justify the complexities.© BrainMass Inc. brainmass.com October 10, 2019, 4:12 am ad1c9bdddf
Please note that the explanation in this response is rather verbal as the solutions in this response make (complete/partial) use of standard/well-known sorting algorithms.
(a) We can use Merge Sort to sort the given set G of m integers (stored in an array of size m) in increasing order.
Merge Sort guarantees O(m*lg(m)) time complexity.
We will use another array of size m to store the result of merging at any merging step in the merge sort, which will ensure no shifting of elements in same array during merging, rather writing the merged subsequences into temporary array as the elements are being merged and later copy the merged content to the ...
The explanation in this response is rather verbal as the solutions presented in this response make (complete/partial) use of standard/well-known sorting algorithms.