I'm stuck on pset3. I'm trying to implement bubble sort but somehow its not sorting at all. Here's my program.
And here's the output.
Thanks.
In the for
loop on line 45, you're iterating i - 1
times while you should iterate through the whole array comparing each adjacent pair of elements together and swapping them as necessary.
the pseudocode for bubble sort is
repeat n times
for each element in the array (excluding the last element)
if the current element is > the next element
swap the current and next elements