Many problems in this world require us to perform a series of steps over and over, looking for the correct result. In computer programming, we have three ways to do this.
Keep it Simple
Of course, if you really want to make this easy for yourself, you just write the solution as one big block. This
Programs are composed of algorithms - recipes for completing simple tasks. The steps used to compose an algorithm can be classified into sequences and decisions.
Sequences and Decisions
A sequence of instructions is a step-by-step flow, with only one possible path. These are the meat of the code, as these do the heavy lifting.
A decision is
A few fun algorithms, all of which are patently slow.
Bogosort - Theoretically, if we randomly shuffle the elements in our list, they will eventually be sorted.
while(LIST not sorted)
Bogobogosort - This is a slower bogosort, if you can believe it. Every time we fail to sort part of the list, we start over at the
Programs are essentially computer recipes - a series of steps and ingredients (variables) which produces a result. However, when dealing with large problems, we have to create larger and larger recipes. This is why we break down individual solutions into processes we call algorithms.
Algorithm - An Overview
An algorithm is a step-by-step solution to a