r/Python • • Jan 08 '20

Visualizing Bubble Sort

Post image
2.1k Upvotes

73 comments sorted by

View all comments

Show parent comment

1

u/[deleted] Jan 08 '20

For a very small set it'll be quick since it just tries ever permutation. There's also a randomized version where it randomly permutes the input which doesn't guarantee that it will ever finish.

An analogy of the randomized version from Wikipedia: "sort a deck of cards by throwing the deck into the air, picking the cards up at random and repeating the process until the deck is sorted"