T3 - Sorting Algorithms

Cards (4)

  • In a bubble sort, each number is compared ascending and is swapped according to which one is larger. This leaves the first sort with the largest number being at the end.
  • In an insertion sort, the first item is compared with the second and swapped if bigger, then the third is compared to the now second and if smaller, first. Then the fourth is compared to the third and, if smaller swapped and compared with the rest. The pattern repeats until the last number in the list is passed down, forming a sorted list.
  • In a merge sort, each item in the list is separated. Then the first and the second are compared, the third and fourth and so on. After each sorted double numbers is created, the first and second double (and so on) are compared to form a new sorted list of four numbers. The lists are then sorted until there's a final sorted list.
  • ^ - exponent - e.g: 5^2 = 25
    MOD - Modulo (remainder) - e.g: 17 MOD 3 = 2
    DIV - Integer division - e.g: 17 DIV 3 = 5