Discrete Chapter 3 Algorithms
Discrete Chapter 3 Algorithms
Discrete Mathematics
Chapter No. 3: Algorithms
Algorithm
An algorithm is a finite sequence of precise instructions for performing a computation or for solving a
problem.
The word "algorithm" refers to a step-by-step method for performing some action. A computer program is,
similarly, a set of instructions that are executed step-by-step for performing some specific task. Algorithm,
however, is a more general term in that the term program refers to a particular programming language.
PROPERTIES OF ALGORITHMS
There are several properties that algorithms generally share. They are useful to keep in mind when algorithms
are described. These properties are:
Input. An algorithm has input values from a specified set.
Output. From each set of input values an algorithm produces output values from a specified set. The output
values are the solution to the problem.
Definiteness. The steps of an algorithm must be defined precisely.
Correctness. An algorithm should produce the correct output values for each set of input values.
Finiteness. An algorithm should produce the desired output after a finite (but perhaps large) number of steps
for any input in the set.
Effectiveness. It must be possible to perform each step of an algorithm exactly and in a finite amount of time.
Generality. The procedure should be applicable for all problems of the desired form, not just for a particular
set of input values.
1|Page
ALGORITHM 2 The Linear Search Algorithm
2|Page
ALGORITHM 5 The Insertion Sort
3|Page