[Chicago] Problems with Merge Sort???
bradley.marts at gmail.com
Mon Jun 15 12:50:12 CEST 2015
Your mergeSort function doesn't return anything. It also doesn't modify the
input list. If it doesn't do one of these two things, you'll never get a
result from it. Assuming you aren't required to write a mergesort that
works in place, I'd recommend you need two return statements in your
recursive mergeSort function (one for the base case, one for the recursive
case), and whenever you call mergeSort you should be assigning the result
P.S. mergeSort looks like the name of a Java method, merge_sort or
mergesort looks like the name of a python function.
On Sun, Jun 14, 2015 at 11:31 PM, Lewit, Douglas <d-lewit at neiu.edu> wrote:
> Hey guys,
> I'm trying to master the merge sort algorithm and definitely experiencing
> some failure. My merge program works great. It takes two arrays, and
> assuming that they are already sorted, the two sorted arrays get merged
> together into one unified sorted array. So that's not the problem.
> The problem is my mergeSort program. I inserted a couple of print
> statements to print out the intermediate results of the recursion, and it
> appears that all my program does is break the array down into pieces and
> then rebuilds the pieces.... into the original array! (Could be worse I
> guess. No error messages! But the output is totally useless.) I'm
> honestly at a loss. I know I'm really close to the right solution, but
> there is something that I'm missing and I can't figure it out. I've been
> struggling with this for a couple days now, and I'm ready to give up. Can
> someone please enlighten me?
> Chicago mailing list
> Chicago at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Chicago