Re: Mergesort


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

Posted by Jason D. Burkert on August 05, 1999 at 17:30:51:

In Reply to: Re: Mergesort posted by stand on August 05, 1999 at 17:21:06:

Thanks. I had overlooked that Quicksort was doing the same thing.

-Jason

: Try this.
: mergesort(arr, temp, 0, n-1);

:
: : 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 ]