QuickSort is giving error idk why | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

QuickSort is giving error idk why

plz help me in QuickSort https://code.sololearn.com/ceCL0QRHNiGC/?ref=app

6th Jun 2022, 7:35 AM
Viraj
Viraj - avatar
3 Answers
+ 1
It tells you why. You're going out of bounds during your sort.
6th Jun 2022, 9:34 AM
Justice
Justice - avatar
0
Justice how can I fix this
6th Jun 2022, 11:35 AM
Viraj
Viraj - avatar
0
more information how it runs [23, 12, 56, 89, 34] start,end|level: 0 4 | 1 pivot: 0 + 2 = 2 (start+count) [56, 12, 23, 89, 34] right: 0 1 | 2 pivot: 0 + 4 = 4 (start+count) [34, 12, 23, 89, 56] right: 0 3 | 3 pivot: 0 + 3 = 3 (start+count) [89, 12, 23, 34, 56] right: 0 2 | 4 pivot: 0 + 5 = 5 (start+count) input[start] = input[pivotPos]; // error at this line ArrayIndexOutOfBoundsException: Index 5 out of bounds for length 5
6th Jun 2022, 9:07 PM
zemiak