Solutions that are inefficient

If computational thinking techniques are applied to the problem of how to bake a cake, on decomposing the problem, the solution would state – among other things – that certain quantities of particular ingredients are needed to make the cake.

For the first ingredient, it might tell us to go the cupboard, get the ingredient, and bring it back to the table. For the second – and all other ingredients – It might tell us to do the same.

If the cake had three ingredients, that would mean three trips to the cupboard. While the program would work like this, it would be unnecessarily long and complicated:

When instructions are repeated and placed in a non-optimised order, this makes the algorithm longer and less efficient.

It would be more efficient to fetch all the ingredients in one go, and the program would be shorter as a result:

An efficient algorithm, with few repeated steps and instructions in the right order, results in a better solution.

The solution is now simpler and more efficient, and has reduced from nine steps to five.

The problem occurred here because some steps were repeated unnecessarily, making the solution inefficient and overly long.