r/Python • • Jan 08 '20

Visualizing Bubble Sort

Post image
2.1k Upvotes

73 comments sorted by

View all comments

Show parent comments

2

u/RunasSudo Jan 09 '20

The reason for that presumably being that, in the first step, the top dot is sorted to the bottom, resulting in everything else shifting upwards – hence the need for an additional column to show that movement explicitly.

1

u/Aeronautix Jan 09 '20

i think the sorting algorithm might be finding the "lowest" value as a starting point. its the same in both this pic and the video with the dancers posted above

1

u/RunasSudo Jan 09 '20

That's how bubble sort works. The (in this illustration) bottom-most element will be sorted into place, then the second from the bottom, third from the bottom and so on. Tom Scott's recent video on this topic is a good introduction.

1

u/Aeronautix Jan 09 '20

ive been staring at this to figure it out like a puzzle

i think ive got it

this is pretty cool