成人快手

Evaluating solutionsSolutions that are inefficient

Before solutions can be programmed, it is important to make sure that it properly satisfies the problem, and that it does so efficiently. This is done through evaluation.

Part of Computer ScienceComputational thinking

Solutions that are inefficient

If techniques are applied to the problem of how to bake a cake, on 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.