• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need help figuring out a quickSort problem

 
Ryan Arment
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am close to finishing this, but now I keep getting into an infinite loop. I am trying to debug but having no luck figuring out where my problem is. I am trying to do a standard quickSort and a quickSort using a stack. But I think the problem is with my partition method. It works on small arrays, up to like 20 but then it gets into an infinite loop. Any help would be greatly appreciated!



 
Ove Lindström
Ranch Hand
Posts: 326
Android Firefox Browser Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at line 12 in quickSortNonRec. There you state that do this as long as stack is not empty.

Then on line 22, 23 and 24, you push things onto the stack. When will it ever break out of the loop??

What is the end state??


Nevermind. I need to look into this a bit more...

Edit: What does the InsertionSorter.insertionSort(arr, start, end); //Sorts the array to the middle value on line 15 of partition do??
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic