The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 398 Weeks Ago, 6 Days Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
Q2 Java : Divide-and-Conquer
A 3-way merge-sort is an algorithm to sort an array A, described as follows:
Divide: divide the array into three (about) equal sized subarrays A[p..q1], A[q1+1..q2] and
A[q2+1..r]
Conquer: Recursively sort these three subarrays.
Combine: Call a procedure 3-way-merge(A, p, q1, q2, r) to merge three sorted subarrays
to a sorted array
(a)(8 points) Please write a recursive pseudocode for this algorithm. Assume the 3-way-merge
procedure is available to be used (you can call it directly).
3-way-merge-sort(A, p, r) // A: the input array, p: starting index,
// r: ending index.
{
}
b) Please write down the recurrence equation for this 3-way-merge-sort algorithm.
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll