0

I'm not quite sure why my merge sort implementation is getting a stackoverflow error. I've reviewed the code multiple times but I'm not getting why this is happening. I tried debugging but have had trouble understanding why the values 0 and 4 (the first and last index of array) never change when I walk through the code. And then finally it throws the stack overflow error.

1 Answer 1

1

The first recursive call to mergesort (line 17?) should use "start, mid", not "start, end". That puts you in an endless loop, so you eventually run out of stack.

Trust your debugger.

Sign up to request clarification or add additional context in comments.

1 Comment

OMG, I can't believe I overlooked that!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.