title: Insertion sort vs Bubble Sort Algorithms
body: <p>I'm trying to understand a few sorting algorithms, but I'm struggling to see the difference in the bubble sort and insertion sort algorithm.</p>
  
  <p>I know both are O(n<sup>2</sup>), but it seems to me that bubble sort just bubbles the maximum value of the array to the top for each pass, while insertion sort just sinks the lowest value to the bottom each pass. Aren't they doing the exact same thing but in different directions?</p>
  
  <p>For insertion sort, the number of comparisons/potential swaps starts at zero and increases each time (ie 0, 1, 2, 3, 4, ..., n) but for bubble sort this same behaviour happens, but at the end of the sorting (ie n, n-1, n-2, ... 0) because bubble sort no longer needs to compare with the last elements as they are sorted.</p>
  
  <p>For all this though, it seems a consensus that insertion sort is better in general. Can anyone tell me why?</p>
  
  <p>Edit: <em>I'm primarily interested in the differences in how the algorithms work, not so much their efficiency or asymptotic complexity.</em></p>