[Chicago] Problems with Merge Sort???

Brad Martsberger 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
to something.

P.S. mergeSort looks like the name of a Java method, merge_sort or
mergesort looks like the name of a python function.

Good luck,
Brad

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?
>
> Thanks!!!
>
> Best,
>
> Douglas.
>
> _______________________________________________
> Chicago mailing list
> Chicago at python.org
> https://mail.python.org/mailman/listinfo/chicago
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/chicago/attachments/20150615/97b21f25/attachment.html>


More information about the Chicago mailing list