What is an Algorithm?
Algorithm is the designed path to perform a specific task or solve a problem. It is the sum of all the steps required to accomplish a task. It is commonly used in computer programming, and all programming languages are based on algorithms.
History of Algorithms
The word Algorithm comes from Ebu Abdullah Muhammed Ibn Musa al-Khwarizmi, who made a significant contribution to the history of mathematics by documenting his algorithmic studies in the 9th century. The Latin translation of his book created a great echo in Europe. Europeans, who could not pronounce the author's name, used the word "algorism" to mean "rules for solving arithmetic problems using Arabic numerals." This word gradually evolved into "algorithm."
An algorithm consists of start, end, and intermediate steps. The operation to be performed at each step is clearly specified, and the next step is taken based on the obtained result. The functioning of computers is entirely based on algorithms.
Let's take a simple example to explain. Consider the table on the side. When a bulb does not work at home, we first ask ourselves if the plug is plugged in. If it's not plugged in, we plug it in. But if it still doesn't light up, then we check if the bulb is blown. If the bulb is blown, we replace it. However, if it's still not resolved, we replace the lamp. As you can see, we unknowingly use an algorithmic approach in many aspects of our lives, just like computers do.
Flowcharts
The graphical representation of the steps in an algorithm is called a flowchart. There are specific symbols in a flowchart, each with a different meaning.
Ellipse: Used at the beginning or end.
Rectangle: Used in general operations.
Parallelogram: Used in data input and output.
Rhombus: Used in comparisons or conditions.
Examples of Algorithms
Example 1: Let's create a flowchart and textual algorithm of a program that takes the average of a student's three exam scores and prints its equivalent in the five-point grading system.
Textual Algorithm
A1 : Enter the first score.
A2 : Enter the second score.
A3 : Enter the third score.
A4 : Sum the numbers.
A5 : Divide the total result by three.
A6 : If the average is >= 85, grade=5, go to A11.
A7 : If the average is >= 70, grade=4, go to A11.
A8 : If the average is >= 60, grade=3, go to A11.
A9 : If the average is >= 50, grade=2, go to A11.
A10 : If the average is >= 0, grade=1, go to A11.
A11 : Print the grade.
A12 : End.
Flowchart