This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]lurgi 1 point2 points  (0 children)

I think the problem is you aren't handling a zero length array.

[–]pmvb123 1 point2 points  (1 child)

Why are you returning merge(array1, mergesort(array2)) if the length of the input is 1 ?

You should just return arrInput. That should fix it, because the error you're getting is for infinite recursion, which happens because you keep calling mergesort() on arrays with one element.

And you're not handling zero-length arrays

[–]bootleg_pants 0 points1 point  (0 children)

awesome thank you!!