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.

## Algorithms

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*= 2*l*+ 2*w*, where*l*= length and*w*= width

we can plug in 5 for *l* to get *P* = 2(5) + 2*w* = 10 + 2*w*. Ultimately, we’re trying to find the different values of *P* for various values of *w*, where

*P*= 10 + 2*w*

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. - Multiply 8 by 2: 8 ⋅ 2 = 16
- Add 10 to the result: 16 + 10 = 26
Here we end up with a perimeter of 26 units. Now let’s discuss some of the properties of algorithms. ## PropertiesIn 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. **Input**: The inputs used in an algorithm must come from a specified set of elements, where the amount and type of inputs are specified.**Output**: The algorithm must specify the output and how it is related to the input.**Definiteness**: The steps in the algorithm must be clearly defined and detailed.**Effectiveness**: The steps in the algorithm must be doable and effective.**Finiteness**: The algorithm must come to an end after a specific number of steps.
When an algorithm satisfies these five properties, it is a fail-proof way to solve the problem for which it was written. ## Sample ProblemTo 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. - Input: The inputs of this algorithm are clearly specified as possible widths of the rectangle. Basically, consists of positive real numbers, since we can’t have a negative width.
- Output: The outputs of the algorithm are also clearly specified as the perimeter of the rectangle based on the given width. Again, we’re dealing with positive real numbers since a perimeter must be positive. Furthermore, the perimeter of this particular rectangle must be greater than 10 since the length of 5 accounts for 10 units of the perimeter.
All together, we’re dealing with outputs of real numbers that are greater than 10. If we get an output that is not a real number greater than 10, then we know we made an error somewhere. - Definiteness: The two steps of the algorithm are clearly defined and detailed. The actions of each step are clearly stated and easy to follow.
- Effectiveness: Each step in the algorithm is very doable. The first step is a matter of multiplication, and the second step is a matter of addition.
- Finiteness: The algorithm comes to an end after two steps, so it is finite. After we complete the second step, we have the perimeter, so the algorithm is complete.
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, ## Lesson SummaryIn 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 For an algorithm to be useful, it must satisfy five properties: - The inputs must be specified.
- The outputs must be specified.
- Definiteness
- Effectiveness
- Finiteness
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! |