- 2
Sort array using bubble sort
1 Odpowiedź
0
Heera Singh Lodhi look closely at your inner loop. It accesses memory outside the array upper bound. Observe, when j is n-1 (the highest index that is within the array bound), the statements access arr[j+1], which is arr[n] and out of bounds.
for(j=0; j<n; j++){
if(arr[j] > arr[j+1]){