Results 1 to 3 of 3
Thread: mergeSort
- 10-10-2009, 01:11 AM #1
Member
- Join Date
- Feb 2009
- Location
- Montreal
- Posts
- 5
- Rep Power
- 0
mergeSort
in class, the teacher showed us the mergeSort recursive algorithm.
I tried to implement it, but for some reasons, it erases the array somehow.
The way i implemented it was to create a class Sortable and methods that i could use on a Sortable object like this:
____
int[] test = new int[] {3,1,2};
Sortable = new Sortable(test);
test.mergeSort;
_____
Here's my code:
java
.pastebin.
com/
m77def8af
Here's the algorithm in pseudo code:
freepdfhosting.
com/
db1d6d7d61.pdf
HELP! ;_;
- 10-10-2009, 06:15 AM #2
You didn't implement the psudocode exactly. Check your merge function against the psudocode, line by line, your mistake lies there.
A hint, did you know that uninitialized values in an int array are set to zero? What happened isn't that your array was erased, but instead you copied a bunch of zero values over the correct values. So, where in your code did you copy values from an uninitialized array? And, did you mean to copy all the values that you copied?Last edited by CodesAway; 10-10-2009 at 06:18 AM.
CodesAway - codesaway.info
writing tools that make writing code a little easier
- 10-11-2009, 10:55 PM #3
Member
- Join Date
- Feb 2009
- Location
- Montreal
- Posts
- 5
- Rep Power
- 0


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks