I am working on the following problem, given input list of length n to two sublists of length n2 , which are recursively sorted and then merged into a sorted list of length n. The merge sort has the recurrence for its time complexity as T (n) = 2T (n/2) + O(n). We can assume that the algorithm is modified such that the input list is split into two sublists of lengths n and n/2, respectively, which are recursively sorted and then merged into a sorted list of length n.
The two main problems that I am trying to solve are:
Give a recursive definition of the worst case time function T (n) for this variant of mergesort;
If the algorithm is again modified to split the list into two sublists of lengths n/10 and 9n/10 what should the time function T(n) be in a recursive form?
Given the algorithm for Mergesort
Input: Anarray of numbers :a[1...n]
Output: A sorted version of this array
function mergesort(a[1 . . . n])
if n > 1: return
else: return merge(mergesort(a[1 . . . ⌊n/2⌋]), mergesort(a[⌊n/2⌋ + 1 . . . n])) a
Then
T(n) = c1 n = 1 else 2*T(n/2) + O(n)
- Given the modified algorithm for Mergesort
Input: Anarray of numbers :a[1...n]
Output: A sorted version of this array
function mergesort(a[1 . . . n])
if n > 1: return
else: return merge(mergesort(a[1 . . . ⌊n/2⌋]), mergesort(a[⌊n/2⌋ + 1 . . . n])) a
function mergesort(a[1 . . . n])
if n > 1: return
else: return merge(mergesort(a[1 . . . ⌊n/10⌋]), mergesort(a[⌊9n/10⌋ + 1 . . . n])) a
Then
T(n) = c1 n = 1 else 10*T(n/10) + O(n)
I would appreciate it if someone could verify this solution. There is never enough time, thank you for yours. Thank you for your integrity. Thank you for your humility. Thank you for your presence.
V.R. E. M. Gertis
given input list of length n to two sublists of length n2
as well as withtwo sublists of lengths n and n/2
. $\endgroup$