0

Bubble sort algorithm

I need help adjusting my bubble sort algorithm: It's not sorting the array, and at the end returns a random string of numbers. what am I doing wrong? https://code.sololearn.com/cieUOC4nHvLX/?ref=app

6th Sep 2017, 6:36 PM
X-1
X-1 - avatar
1 ответ
+ 7
Use i<size instead of i<=size :) Since the array size is 4, the valid indices are 0, 1, 2, 3. We can't include 4 as the index. https://code.sololearn.com/cmk9nW6aXATA/?ref=app
6th Sep 2017, 7:08 PM
Shamima Yasmin
Shamima Yasmin - avatar