Algorithms are a set of step-by-step instructions that satisfy a certain set of properties. In this lesson, we’ll explore the properties an algorithm must satisfy in order to be useful using an example.
Have you ever tried to assemble a piece of furniture by yourself? If so, you probably used a set of step-by-step instructions to assist you in your endeavor. Wouldn’t it be nice if math problems came with a set of instructions like this? Oh wait, they do!When solving a math problem, we usually use an algorithm, or a set of step-by-step instructions. For example, suppose we’re trying to figure out what the perimeter of a rectangle with length 5 units would be for various widths.
Since the formula for the perimeter of a rectangle is:
- P = 2l + 2w, where l = length and w = width
we can plug in 5 for l to get P = 2(5) + 2w = 10 + 2w. Ultimately, we’re trying to find the different values of P for various values of w, where
- P = 10 + 2w
To figure out the perimeter for this rectangle, for some width w, we follow these steps:
- Multiply w by 2.
- Add 10 to the result. This is the perimeter.
|This is an example of an algorithm. It is a set of steps that we can follow in order to find the perimeter of the rectangle for a given width, w. Now suppose we want to know what the perimeter of this rectangle would be if it had a width of 8 units.
Again, we can use our algorithm.
Here we end up with a perimeter of 26 units. Now let’s discuss some of the properties of algorithms.
In order for an algorithm to be useful, it must help us find a solution to a specific problem. For that to happen, an algorithm must satisfy five properties.
When an algorithm satisfies these five properties, it is a fail-proof way to solve the problem for which it was written.
To further our understanding of these five properties, let’s take a look at our opening example where we used an algorithm to find the perimeter of a rectangle with length 5 units for various widths and see how it satisfies each of the properties.
Since our algorithm satisfies the five properties of an algorithm, it can always be used to find the perimeter of a rectangle, with length of 5 units, for some width, w.
In the same way that a piece of furniture can be assembled by following a set of step-by-step instructions, a math problem can be solved using an algorithm. An algorithm is a set of step-by-step instructions used to solve a math problem.
For an algorithm to be useful, it must satisfy five properties:
When an algorithm satisfies these properties, it is fail-proof method for solving a designated type of problem. As such, algorithms are useful, not only in mathematics and computer programming, but also in any other area where step-by-step instructions are beneficial.
For example, you may have never have thought of a dinner recipe as a mathematical concept, but now that you know the directions are a type of algorithm, you may never look at them in the same way again!