Algorithm
An algorithm is a set of instructions that allows you to solve a problem.
Each instruction is simple and repeatable. It’s important to understand that the instructions work on all similar problems, not just one.
Here’s an algorithm for sorting any set of numbers, to get them into order. Start with 4,3,5,6,2 for example.
The bubble sort algorithm is simple. Compare two numbers. If the first number is higher than the second, switch them. So now it’s 3,4,5,6,2. Next step is to compare positions two and three. If the second is higher than the third (it’s not) switch them. Repeat for the whole string. Then start over. Do it over and over again until you can go the whole way with no switching. Done.
More here from Seth.
leave a comment