Mergesort


[ Follow Ups ] [ Post Followup ] [ CS2604 Discussion WWWBoard ] [ FAQ ]

Posted by Jason D. Burkert on August 05, 1999 at 16:51:58:

I'm having trouble implementing Mergesort. When I execute mergesort on an array with random values, it returns a sorted array, however, the largest value from the original list has been replaced with a 0.

For example, this is what happens...

Elem arr[n] = [424, 21, 928, 7] //for the sake of example
Elem temp[n] = []

mergesort(arr, temp, 0, n);

arr = [0, 7, 21, 424]; //it has been ordered correctly, but 928 was replaced with 0.

I copied the code for mergesort from the book. I have checked and rechecked it. I have tried both implementations on page 243 and they are both doing the same thing. What's wrong?


Follow Ups:



Post a Followup

Name:
E-Mail:

Subject:

Comments:

Optional Link URL:
Link Title:
Optional Image URL:


[ Follow Ups ] [ Post Followup ] [ CS2604 Discussion WWWBoard ] [ FAQ ]