MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programming/comments/e55j0i/bubble_sort_visualization/f9jop2x/?context=9999
r/programming • u/pedrovhb • Dec 02 '19
268 comments sorted by
View all comments
724
good implementations of bubblesort won't do the extra comparisons after the n-kth index (n elements, kth iteration). Also, it can be very fast to check if the list is sorted rather than possibly wasting a few useless iterations
117 u/pedrovhb Dec 02 '19 Perhaps the title should be "Naive bubble sort visualization" (: 36 u/hylet Dec 03 '19 more like "paranoid bubble sort", keeps checking the last elements even though they are sorted 15 u/[deleted] Dec 03 '19 [removed] — view removed comment 3 u/SmokeyDBear Dec 03 '19 bubblesortandhash
117
Perhaps the title should be "Naive bubble sort visualization" (:
36 u/hylet Dec 03 '19 more like "paranoid bubble sort", keeps checking the last elements even though they are sorted 15 u/[deleted] Dec 03 '19 [removed] — view removed comment 3 u/SmokeyDBear Dec 03 '19 bubblesortandhash
36
more like "paranoid bubble sort", keeps checking the last elements even though they are sorted
15 u/[deleted] Dec 03 '19 [removed] — view removed comment 3 u/SmokeyDBear Dec 03 '19 bubblesortandhash
15
[removed] — view removed comment
3 u/SmokeyDBear Dec 03 '19 bubblesortandhash
3
bubblesortandhash
724
u/IdiotCharizard Dec 02 '19
good implementations of bubblesort won't do the extra comparisons after the n-kth index (n elements, kth iteration). Also, it can be very fast to check if the list is sorted rather than possibly wasting a few useless iterations