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 ofinstructionsfor how to do something, others can simplyfollowthose instructions to solve the same problem
Sortingalgorithm
A set ofinstructionsused to put a list ofvaluesinto order
Searchingalgorithm
An algorithm used to findavaluewithin alist, or to confirm that value is not present
Bubblesort
1. Comparepairsof values
2. Swap if inwrong order
3. Repeatfor further pairs
4. Repeat until pass with noswaps
Bubble sort
The algorithm will repeat until apasshas been completed with noswapsoccurring. Once this happens, the list is guaranteed to be in order.
Insertion sort
1. Split list intosortedandunsortedsides
2. Take each item fromunsortedside and insert into correct place in sorted side
Insertion sort
Unlike a bubble sort, an insertion sort does not requiremultiplepasses 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. Dividethe original list intosublists
2. Mergethesublistsback together in order
Mergesort
The'divideandconquer'approach splits the data up into individual lists and then merges them back together in order.