Have you heard of algorithms? It may sound foreign to you, but algorithms
are an important foundation for solving problems with computer systems, you
know.
In simple terms, an algorithm is an arrangement of steps or methods to
solve a problem systematically and logically.
To be able to recognize it, the algorithm has the following
characteristics:
1. Having input or input,
2. Having an output or output,
3. Describe steps that are definite, clear, and unambiguous,
4. The steps used are simple,
5. Have a time limit.
Check out the explanation of the working principle, structure, and way of
presenting algorithms in computer programming, which is quoted from the book
Algorithms and Programming by Lamhot Sitorus.
Algorithm
Working Principle
Basically, the algorithm is a description of the process to do something
that is arranged in a series of actions. In simple terms, the working principle
of the algorithm is divided into, input (input), process, and output (output).
Based on the example above, the input is raw eggs and the output is cooked
omelet. Thus, the arrangement of the algorithm becomes as follows:
1. Turn on the stove fire,
2. Pour the oil into the pan,
3. Crack the chicken eggs into a bowl,
4. Pour salt to taste,
5. Beat the egg and salt mixture,
6. Pour the egg mixture into the pan,
7. Cook the eggs until cooked.
Algorithm
Basic Structure
In general, the basic structure of the algorithm consists of sequential
(sequential), test conditions or branching (branching), and looping (looping).
1.
Sequential Algorithm
Example:
The algorithm has four lines of action, namely t1, t2, t3, and t4, then all
actions will be carried out sequentially starting from actions t1 to t4.
2.
Branching Algorithm (Branching)
In everyday life there are times when an activity will be carried out and
not carried out depending on certain situations. Likewise with algorithms,
there are times when one or several actions will be carried out and not carried
out depending on certain situations.
Well, the structure of this branching algorithm is used to perform one
action from several given choices.
3.
Looping Algorithm
Similar to humans, algorithms also recognize repetition activities, namely
doing one or several activities repeatedly. However, unlike humans, computers
do not recognize the term tired or bored in doing the same activities over and
over again.
Thus, the looping structure is used to carry out activities that are
carried out repeatedly.
How
to Present Algorithm
The presentation of the algorithm will be better if it is written
systematically. There are three ways that you can use to present algorithms,
namely narratively, flowcharts or diagrams / flowcharts, and pseudocode.
1.
Narrative
Narrative presentation of the algorithm is written using stories as in
everyday language.
Example: Calculating the area of a triangle using narrative
Step-1 : Start
Step-2 : Read the Base value
Step-3 : Read High value
Step-4 : Calculate Area = (base x height) / 2
Step-5 : Print Area Results
Step-6: Done
2.
Flowchart
With flowcharts, the way the algorithm is presented is made in a sequence
of special symbols. The order of symbols is drawn according to the direction of
the arrows.
Example:
3.
Pseudocode
These troubleshooting steps are written in a way that resembles or resembles
a program. Pseudocode is not specific to one programming language so that this
algorithm can be translated according to the programming language in a program.
Example: Calculating the area of a triangle using pseudocode
Input (Plinth)
Input (High)
Area (Base x Height) / 2
Output (Area)
Although there are three different ways of presenting, the result of the
algorithm given remains the same. Therefore, there is no rule that states must
use a certain presentation. You are free to choose the form of presentation
according to your wishes and understanding.
Even so, the algorithm made with sentences has a weakness, namely that it
can only be understood by practitioners who understand the language.