Algorithms:

One of the most important topics associated with software development is algorithm development.  An algorithm is defined as the steps necessary to provide a solution to a given task.  If the programmer is unable to solve the problem at hand on paper, then the programmer has little if no chance at all of solving the problem with a microcontroller through the use of software.  The software and microcontroller are simply tools to implement a solution.  Some problems must be solved by a specific order of steps while other problems may be solved through a variety of different combinations of steps.  For example, in order to add a series of numbers to find the total sum, the order in which the numbers are added does not matter or make a difference.  On the other hand, some problems do require a specific order.  For instance, converting a temperature from degrees Fahrenheit to degrees Celsius requires the number 32 to be subtracted from the Fahrenheit value before the value is multiplied by 5/9.  Multiplying by 5/9 first and then subtracting 32 will produce the wrong equivalent temperature.  This section is dedicated to understanding how to develop a solution.

An algorithm is a step-by-step method for solving a problem.  Enough detail is required so that a person unfamiliar with the problem could follow the steps and arrive at the desired solution.  Computers are extremely powerful tools used to solve problems.  However, before a computer can solve a problem, a programmer must specify the order and the actual instructions to follow to solve the problem.

The items listed below will be used to describe an algorithm.  The steps of the algorithm should be stated clearly and precisely.  Anyone following the algorithm must obtain a unique value for each of the steps along the way to the solution.  For example, anyone adding two numbers together should arrive at the same answer.  In addition, the algorithm can only rely on information already stated in the algorithm or information that has been derived during the algorithm.  An algorithm cannot use information that it does not have.  The algorithm must have a definite starting and stopping point, providing a finite number of instructions to be executed.  The algorithm must list the input information for the system as well as the specific range or ranges for which the algorithm covers.  If an algorithm holds true for only positive integers, then the algorithm must clearly state this fact.  The algorithm must state the outputs that are produced.  When possible, algorithms should be kept general to allow re-use for different sets of data.  For example, an algorithm designed to average a set of numbers should work for any number of terms.

Algorithms:

1. Precision:        The steps are clearly stated.
2. Uniqueness:    The intermediate results of each step of execution are uniquely defined and depend only on the input and results of the preceding steps.
3. Finiteness:       The algorithm stops after a finite number of instructions have been executed.
4. Input:                 The algorithm receives input.
5. Output:              The algorithm produces output.
6. Generality:        The algorithm applies to a set of inputs.

Example 1 - Adding a series of numbers.

Example 2 - Averaging a set of numbers.

Example 3 - Calculate the slope of a line.

 Last Updated on March 19, 2003 main contact EET 209