How is bubbling efficient if it has to go through the list over and over again? Why would one use it?
One reason to use bubble sort is that it works: when the algorithm finishes, the list is definitely sorted. Another reason to use it is that it is easy to understand and reasonably simple to code. As for efficiency, it depends what you mean by "efficient"... while O(n2) is the slowest runtime we've seen so far this semester, it is actually pretty fast in the grand scheme of algorithms. Imagine an algorithm that takes O(n3) or O(n10) or O(n10000) time!
Why would you use bubble sort vs. selection sort?
One reason is that bubble sort is a little easier to understand and simpler to write --- compare our two nested for loops for bubble sort with the nested for loops we used for selection sort.
Is bubble sort more efficient than selection sort?
As we'll see next time, both bubble and selection sort have runtimes of O(n2).