• Post Reply Bookmark Topic Watch Topic
  • New Topic

quicksort recursively  RSS feed

 
Mohamad Samy
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i wrote the following code but it always gives me stack over flow error,
 
Paul Clapham
Sheriff
Posts: 22841
43
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If your recursive method always calls itself, then you are going to have an infinite loop. In this case it's the stack overflow error which tells you that's happening. So your recursive method shouldn't always call itself. In other words there should be some condition under which the recursive call doesn't take place.

So in your code it's lines 35 and 36 which are recursively called unconditionally. You need to find some condition under which they don't need to be called.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!