| Author |
Message |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 03/19/2006 03:46:50
|
mona
Newbie
Joined: 03/19/2006 03:44:03
Messages: 2
Offline
|
HI
Plz if someone can help me with the following question
Show the steps involved in sorting the following array of names into ------alphabetical order using the Merge sort algorithm.
----------------------------------------------------
Neo - Trinity - Morpheus- Smith - Cypher-
----------------------------------------------------
Thanks
Mona
|
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 03/19/2006 06:27:03
|
destin
Newbie
Joined: 01/07/2006 19:13:04
Messages: 224
Offline
|
Well, obviously before you answer this you're going to need to know what the merge sort algorithm is and how it works. If you don't already know, here's an article on wikipedia that explains it. If you do know, then what part of it are you having trouble with?
|
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 03/21/2006 01:30:48
|
mona
Newbie
Joined: 03/19/2006 03:44:03
Messages: 2
Offline
|
i can understand the merge sort be reading thrugh that doc. considering following pseudocode for the Merge sort algorithm For the above array of 5 elements iam not able to list all the calls to mergeSort that will be made, clearly indicating the actual parameters for each invocation of the method. Plz if anyone can at least demonstarte the calls
Array version: A is the array to be sorted
METHOD mergeSort(A, lowerBound, upperBound)
IF A contains more than one element
middle = (lowerBound + upperBound) / 2
mergeSort(A, lowerBound, middle)
mergeSort(A, middle+1, upperBound)
merge(A, lowerBound, middle+1, upperBound)
ENDIF
ENDMETHOD
thax
Mona
|
|
|
 |
|
|