简体   繁体   中英

Java Mergesort Implementation having a stackoverflow error

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM