Sorting

Selection sort

  1. Mark the position of the starting card as both start and lowest value.

  2. Move from left to right marking the position of the lowest valued card.

  3. When you get to the end of the list swap the lowest card you found with the starting card.

  4. Go back to step 1 with the next card from the left as the starting/lowest card until the starting card is the last card.

Insertion sort

Starting with the second card from the left:

  1. Compare the current card with the one to its left. If it is less than that card, swap them, and continue comparing with cards to the left.

  2. Once the current card is greater than the card to it’s left, go back to step 1 starting at the next position to the right.

  3. Repeat until you have finished all the cards.

Comparison

After sorting your cards go through the both the selection sort and insertion sort procedures counting how many comparisons you perform.

Put the cards in reverse order and sort with selection sort and count both how many comparisons you do and how many swaps you perform.

Then put the cards in reverse order again and sort with insertion sort and count both comparisons and swaps.

Video

15 Sorting Algorithms in 6 Minutes