Types of sort

Cards (10)

  • Algorithm
    A clever set of instructions for how to do something
  • One of the great things about an algorithm is that it can be reused; once a computer program has written down a clever set of instructions for how to do something, others can simply follow those instructions to solve the same problem
  • Sorting algorithm
    A set of instructions used to put a list of values into order
  • Searching algorithm
    An algorithm used to find a value within a list, or to confirm that value is not present
  • Bubble sort
    1. Compare pairs of values
    2. Swap if in wrong order
    3. Repeat for further pairs
    4. Repeat until pass with no swaps
  • Bubble sort

    • The algorithm will repeat until a pass has been completed with no swaps occurring. Once this happens, the list is guaranteed to be in order.
  • Insertion sort

    1. Split list into sorted and unsorted sides
    2. Take each item from unsorted side and insert into correct place in sorted side
  • Insertion sort
    • Unlike a bubble sort, an insertion sort does not require multiple passes to check the values are in order; once each value has been inserted into the sorted list, the list as a whole will be in order.
  • Merge sort

    1. Divide the original list into sublists
    2. Merge the sublists back together in order
  • Merge sort
    • The 'divide and conquer' approach splits the data up into individual lists and then merges them back together in order.