Video: Optimized Bubble Sort

Staff Pick: Summertime According to NICERC
April 26, 2018
Staff Pick: Just Go with the Electron Flow
May 7, 2018

Video: Optimized Bubble Sort

NICERC’s Computer Science curriculum covers several traditional sorting algorithms that can be used to sort a list of items. One of the covered algorithms in the curriculum  is bubble sort.

Bubble sort makes pairwise comparisons that result in larger numbers “bubbling” to the end of the list. A traditional bubble sort must iterate a specific number of times to guarantee the list is sorted when the algorithm terminates.  Optimized bubble sort potentially shortens the length of a bubble sort by including a variable that stores whether or not a swap was made during an iteration. If no swaps are made during an iteration, the algorithm terminates since the lack of a swap would indicate that the items are already sorted.

Check out this video for a visualized example of an optimized bubble sort.

 

Learn more about our Computer Science curriculum and request access here.

Check out other helpful videos from NICERC on our YouTube channel!


 

This video comes from NICERC Curriculum Development Specialist Josh Coriell