- Published on
The Algorithm Design Manual (3rd) Exercise Solution 'E4-30'
Table of Contents
Introduction
This series is my solutions for algorithm exercises in'The Algorithm Design Manual' 3rd edition.
It's my solutions, not model answers, so if you find some mistakes or more sophisticated solutions, please post in comment area below.
Repository
Exercise 4-30
Question
Consider again the problem of merging sorted length- arrays into a single sorted length- array. Consider the algorithm that first divides the arrays into pairs of arrays, and uses the merge subroutine to combine each pair, resulting in sorted length- arrays. The algorithm repeats this step until there is only one length-kn sorted array. What is the running time as a function of and ?
Solution
Let be the height og the repetition operation of merging of two arrays of equal length.
By using the same analysis of Mergesort, the constraint of is:
In each height of repetition, merging takes time.
So, Running-time is .