Algorithms and Big-O-Notation

Course Home

An algorithm is a set of rules which are designed to help us solve a problem. You could argue a whole system is one big algorithm, but we tend to think about them as more granular.

As mentioned in the BBC Bitesize video (below), it’s important to design the algorithm before you start to code. If you watch the bitesize video, they talk about the act of brushing your teeth. So we have to design the algorithm first before implementing the code.

1. Pick up toothbrush
2. Wet toothbrush
3. Pick up tooth paste
4. Open tooth paste
5. Put some tooth paste on the toothbrush
6. Open mouth
7. Put toothbrush in mouth
8. Brush teeth with the toothbrush
9. Rinse mouth with water
10. Put toothbrush back down

Taking the above scenario for brushing your teeth, once we have the outline, we can look at designing and implementing an algorithm that will address the steps and ideas of the process.

Now, the above scenario also shows the difficulty with programming and automation. The majority of readers here will probably be testers, so will have seen many test cases similar to the above. We could pick many holes in this algorithm, such as:

1. How do you pick up the toothbrush?
2. Wet the toothbrush - Do I wet the handle? Or the head? Or the whole toothbrush?
3. How do I pick up the toothpaste? Which hand do I use? Which part of the tube? Is it even a tube?
4. Put ‘some’ on the toothbrush - how much is that?
5. Open mouth. How wide?
6. Rinse mouth? The outside or inside of my mouth?

We could go on. I added this because programming is difficult, but to also emphasize the huge difference between designing and implementing code.

Big-O-Notation

I thought about explaining this, but quite frankly I cannot do as good a job as ‘cletus’ on StackOverflow.
In short, big-o-notation is a model to describe the complexity of an algorithm. I encourage you to check out the explanation linked above.

Author