ALGORITHM

ALGORITHM
Algorithm is step by step procedures that provide a solution to a specific problem.
CHARACTERISTICS OF ALGORITHM
A good algorithm should have the following characteristics;
1. Finiteness: there is exact number of steps to be taken and has an end.
2. Unambiguous: it must be easy to understand the procedure.
3. Sequence of execution: instructions are performed from top to bottom.
4. Effectiveness: it must give the correct answer.
5. Input specified: must specify the type, amount and from of data to be used during the algorithm.

SOME OPERATIONS WITH ALGORITHM;
Writing algorithm for: a. computing average of a given set of numbers. b. Evaluation of equation Y=a(b-c)2 / d + 2 c. printing out the first ten odd numbers

Solutions
1. An algorithm that computes the average of a given set of numbers.
i. c = 1 ( use to count the numbers processed)
ii. Sum = 0
iii. If c > sum: go to line viii
iv. Sum = sum + c
v. c = c + 1
vi. Go to line iii
vii average = sum/c
viii. Print the average
ix. End.

2. An algorithm that evaluates Y=a(b-c)2 /d + 2
i. input the values a,b,c,d
ii. Y=a*(b-c)^2 /(d + 2)
iii. Print Y

3. An algorithm that prints out the first ten odd numbers.
i. Count =0
ii. Sum=1
iii. Sum =sum + count
iv. If count > 10, go to line viii
v. Count = count + 2
vi. Go to line iii
vii. Average = sum/num
viii. Print average
ix. End

Another example
Compute the average of a given number.
Let N be the number of the given set.
Get the formular (Ave = sum/N)
Get the numbers
Find the sum of the number
Calculate the average
Print the output
End

Skip to toolbar