0
QuickSort is giving error idk why
plz help me in QuickSort https://code.sololearn.com/ceCL0QRHNiGC/?ref=app
3 Antworten
+ 1
It tells you why. You're going out of bounds during your sort.
0
Justice how can I fix this
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