First is algorithm or their short form, algo .
What is it actually ?
To describe it in pure mathematical form [with the theorem and equations] is somewhat difficult (at least for me), but let me give an examples for a clear illustrations (perhaps maybe in a too simple but maybe a bit long winded analogies).
Say ... you go shopping (with environmental friendly bag) in a big giant hypermarket.
And you see tomato priced at $6.80 per kg and also meat priced at $14.90 per kg.
So you decided to buy 1kg of tomato and 1kg of meat
So now is where the algorithm part coming. Then, you would want to know how much it costs for 1kg of tomato and 1 kg of meat.
We need the addition operations to sum up the total price of both groceries that we buy.
It maybe hard to compute in head (maybe you are maths king) but let us compute in the a piece of used paper.
Following describes the additions operations for tomato and meat step by step in algorithms.
Step 1:
Write down and align both numbers in columns from the right.Make sure that price listed is only up to 2 decimal points.
Step 2:
Starting from rightmost columns, work out the additions to the left columns by columns through various columns
Step 3:
Compute summations and write down the summations of the digits of same columns. If the addition produces overflow (summation more than 10) , carry the overflow to its next left columns Make a small mark number 1 to denote any overflow from its right columns.
Step 4:
If there are no columns to the left, stop.
Otherwise, move to next columns to left and repeat Step 3.
(Side joke: Thanks to certain governing entity failing to curb out the rising inflation of foodstuffs)
So you had $50 inside the purse/wallet. So, you handed over the $50 to the grocers and you expect that there are balances.
Now, let assumes that you are a grocers and you need to compute what amount of balances that you should give back to the customer.
Same as above, we need algorithms again but now we need minus operations to find out the balances to give back to customer.
Again, we discuss algorithm but this time it is minus operation for $50 and $21.70.
Step 1:
First, we write down the two number but the larger number is above the smaller number and both are aligned from the rightmost columns.
Step 2:
Starting from rightmost columns, work out the subtractions to the left columns by columns through various columns
Step 3:
Compute summations and write down the summations of the digits of same columns. If subtraction produces negative digit, borrow 1 from top number to the left. The current columns which is worked on are given "10" for it to be subtracted.
Step 4:
If there are no columns to the left, stop.
Otherwise, move to next columns to left and repeat Step 3.
So the grocers should give balances of $28.30 back to customer.
As you seen from 2 examples above, we can see how the algorithms are working. Besides used extensively in numerical computations, algorithms can be seen as recipe (not necessary restricted to cooking only) which contains of instructions which acts as solutions for the problems given.
Below I summarized the characteristic of the algorithms . . .
(1) Algorithms have consisted a finite number of instructions. (4 steps in both addition and subtraction)
(2) The individual instructions should be very well defined for the computing agents ( in this case : customer and grocers) to be able to execute or perform execution effectively.
(3) Algorithms solves a general class of problems (General in case of subtractions where it is applicable for the balances should be greater than $0.00)
(4) Algorithms will halt after the solutions is found (See the Step 4 in both of the examples)
Okay, that's all. If you found anything missing or anything wrong, just left it in comments below. ^_^
No comments:
Post a Comment