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.
CS50 Stack Exchange is a question and answer site for students of Harvard University's CS50. It only takes a minute to sign up.Sign up to join this community
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