Question

In: Computer Science

The multi-merge sort algorithm (M&M sort) works like merge sort, except that instead of dividing the...

The multi-merge sort algorithm (M&M sort) works like merge sort, except that instead of dividing the array into 2 partitions, it divides the array into p partitions. It recursively sorts each of the p partitions and then merges the results doing a p-way merge (except, of course, for the base case of a singleton or empty array). (a) Write the recurrence for T(n) for M&M sort for the case where p is a constant. Then, give a closed-form solution to the recurrence using the Master Theorem, and note which case applied. (b) Now assume that p is not a constant, but rather p(n) = n/10. Rewrite T(n) for this case. Then, give a closed form solution. Use the Master Theorem if it applies, or any other means of arriving at the result.

Solutions

Expert Solution

(a) Doing a p-way merge sort requires breaking the array into p partitions at each step. So, in each step we need to solve p problems of the size n/p, and then merge them. Therefore it takes T(n) time to sort an array of length n where
and where c is a constant.

This can be solved using the Master's Theorem, we since the relation is of the form where and . Here the function f(n) is in =. So, .

(b) If we divide the array into n/10 partitions at each step, where n is the length of the array at the previous step, then at each step we solve n/10 problems each of length 10, and merge them. Therefore to sort an array of length n it takes T(n) time where and where c and c' are constants. The solution of this recurrence is not possible using Master's theorem as it is not in the form where a and b are constants. But since T(10) is a constant we got the closed form as T(n)=c'n.


Related Solutions

USING JAVA Almost sort the array using Merge Sort. Perform Merge Sort as usual except that...
USING JAVA Almost sort the array using Merge Sort. Perform Merge Sort as usual except that during the final merge, it is not necessary to merge all n elements, but only the elements in positions 1 to k.
Analyzing Selection Sort Algorithm The selection sort algorithm works by first finding the smallest value in...
Analyzing Selection Sort Algorithm The selection sort algorithm works by first finding the smallest value in a list and swapping the first value with it, then finding the second smallest value and swapping the second value with it, continuing until all the values are in order. Implement this algorithm, then determine its growth function, and hence the order of the algorithm. Find how many swaps are made. Use Java Code to create algorithm
Write a function in C that uses the Merge Sort sorting algorithm with arrays. The function...
Write a function in C that uses the Merge Sort sorting algorithm with arrays. The function must not be void and must output type int* i.e. it must take the form: int* merge_sort(int a[], int n) where a[ ] is the input matrix and n is the size of the matrix. You may use an auxiliary functions such as "merge." The returned array should be sorted using merge_sort and should not modify the array that was input (a[ ] ).
a. Develop a divide-and-conquer algorithm to perform a parallel merge sort of an array. Hint: After...
a. Develop a divide-and-conquer algorithm to perform a parallel merge sort of an array. Hint: After division, each process sorts its part of the array using an efficient algorithm. Then, the subarrays are merged into larger sorted subarrays. b. Analyze the communication and computation times if the number of processes is equal to the number of array elements, n. c. Repeat Part b if the number of processes is less than the number of array elements. Assume that the computation...
Ryan is implementing a merge sort algorithm that he heard about in computers class. However, he...
Ryan is implementing a merge sort algorithm that he heard about in computers class. However, he was not paying attention, and ended up implementing the merge sort in a very unusual way. The standard merge sort takes a list, and recursively splits it in half, until there is only one element left. It then uses the idea that two sorted lists can be easily merged in O(n) time using "two pointer technique" (this step is usually called merge). Ryan does...
Create a quick and merge sort algorithm that sorts 6 9 8 12 3 1 7...
Create a quick and merge sort algorithm that sorts 6 9 8 12 3 1 7 In java please.
(Write a C# program DO NOT USE CLASS)Implement the merge sort algorithm using a linked list...
(Write a C# program DO NOT USE CLASS)Implement the merge sort algorithm using a linked list instead of arrays. You can use any kind of a linked structure, such as single, double, circular lists, stacks and/or queues. You can populate your list from an explicitly defined array in your program. HINT: You will not be using low, middle and high anymore. For finding the middle point, traverse through the linked list while keeping count of the number of nodes. Break...
Design and analysis of Algorithms: How do I write a k way merge sort algorithm from...
Design and analysis of Algorithms: How do I write a k way merge sort algorithm from a merge sort algorithm that splits 2 arrays while sorting?
Write a program that performs a merge-sort algorithm without using a recursion. c++ programming language(Only #inlclude...
Write a program that performs a merge-sort algorithm without using a recursion. c++ programming language(Only #inlclude <iostream>)
Modify the quicksort algorithm such that it uses the last item as the pivot instead of the 1st. Also, sort in descending order, instead of ascending order.
Programming Language : JavaModify the quicksort algorithm such that it uses the last item as the pivot instead of the 1st. Also, sort in descending order, instead of ascending order.NOTE: Do not move the last element into the first element of the array. You must treat the algorithm as if the pivot is actually sitting in the last location of the array.After it has been sorted in descending order, go through all the items in the array and make sure...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT