• Post Reply Bookmark Topic Watch Topic
  • New Topic

Quick Sort (recursive) Descending - ArrayIndexOutofBounds?  RSS feed

 
Aarden Axford
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all, I've been tasked to write a recursive algorithm for the quick sort function, which I have nearly completed. However, I am continually getting an "indexoutofbounds" error. This error ONLY seems to occur when I set the arraySize to 5. In the program I am writing, the user specifies how many random numbers they want sorted, and whether they want them sorted ascending or descending. I've gotten ascending to work fine, but when the arraySize is 5, I continually get "ArrayIndexOutofBounds" errors. Here is my code:



Any suggestions/tips? I am fairly new to ArrayIndexOutofBounds exceptions, so I am unsure of how to necessarily fix them.
 
Tushar Goel
Ranch Hand
Posts: 934
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are the left and right values you are using?
 
Carey Brown
Saloon Keeper
Posts: 3310
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Move your "PIVOT:" print statement above the line that's giving you grief and add left and right to the print statement.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!