Understanding the Basic and Type of Algorithm

Basic and Type of Algorithm

Basic Algorithm


In a simple algorithm can be referred to as a way of doing things. Algorithms can also be defined as the sequences of how a problem is solved. Nevertheless, the experts agreed to define algorithms as logical sequences in the decision to solve a particular problem.

Fundamentals of algorithm needs to be clearly understood by a programmer that programs be made more effective and efficient. As an example, let us discuss how the algorithm in making noodles boiled. What would you do first to make boiled noodles?

The first step of course you have to open the packs of noodles boiled. After that, you will prepare a cooked water for approximately 5-10 minutes. When the cooking water and start to boil, remove it from the wrapper and noodles boiled then input into the cooking water boiling.

While the noodles boiled, remove the spices in a pack, then open the pack of seasoning and pour into the prepared dishes. If you see the noodles have cooked, prepare the filter, and then strain the noodles that have been cooked.

Pour the noodles that have been cooked into the dish which had contained seasoning. Give a little hot water to replace the water that has been boiled before you waste.

The sequences are indeed looks quite logical. The sequences are indeed looks quite simple because the issue presented is not too complex. Then, what if the problem faced quite complex? Of course this requires a special strategy in designing appropriate algorithms.

Algorithm Type


Based on the type, the algorithm can be divided into 3, which is as follows.

1. Sequence


This algorithm requires the type of logical sequencing of each phase of problem solving. One example of this type of algorithm is cooking noodles boiled over. Precedence should not be reversed, in order to form a logical sequence of work.

2. Selection


This type of algorithm allows to choose between the two conditions to be selected. The conditions to be selected must be declared at the beginning. One can use this type of algorithm is the selection of the maximum value between two numbers.

The first step to consider is to declare the type of data used. In this discussion we directly discuss how the algorithm to determine the maximum value.

Select figures will be compared. Then, save the figure. Choose a second number, and then save it. Then, compare these two numbers. If the first number is larger, then the two numbers do not need to be exchanged. If the first number is smaller, the two exchanged numbers. When the algorithm written in pseudo code <em> </ em> is as follows

A <- X
B <- Y

If A> B then
A <- X
B <- Y else
A <- Y
B <- X
end if

3. Repetition


This type of algorithm is necessary when you need to repeat a certain step in your problem solving method. This type is typically used to save a wet algorithm used. There are several procedures that can be used to use this method for whom the procedure, procedure repeat-until, and procedures while-do.

One example of a simple problem in solving this problem is to write the word "Hello" five times without having to write down the procedure of writing the word "Hello" is as much as five times.

By eliminating the variable declaration at the beginning, Pseudo code that can be written here is as follows:

for i <- 1 to 5 do
output ("Hello")
end for

0 comments:

Post a Comment