News for hackers. Stuff that matters.
Re:Back in 1993, I was taking a number theory class by tzs on Tuesday May 04, 2021 @10:46AM (#27038163)
> Bubble sort, on the other hand, requires you to reason about consecutive adjacent swaps, keep track of whether the current iteration dirtied the array, and so on.

You only need to keep track of whether or not the current iteration dirtied the array if you want to stop as soon as a pass leaves the array sorted. If you don't want to do that (or don't think of it) then it is just something like:

  for pass = 1 to n
    for index = 1 to n-1
      if array[index-1] > array[index]
        tmp = array[index]
        array[index-1] = array[index]
        array[index] = tmp
There is less extra to keep track of then in insertion or selection sort.

There are no comments on this comment yet.