What is an Algorithm
What is an Algorithm
Characteristics of an Algorithm
The following are the characteristics of an algorithm:
o Input: An algorithm has some input values. We can pass 0 or some input
value to an algorithm.
o Output: We will get 1 or more output at the end of an algorithm.
o Unambiguity: An algorithm should be unambiguous which means that
the instructions in an algorithm should be clear and simple.
o Finiteness: An algorithm should have finiteness. Here, finiteness means
that the algorithm should contain a limited number of instructions, i.e.,
the instructions should be countable.
o Effectiveness: An algorithm should be effective as each instruction in an
algorithm affects the overall process.
o Language independent: An algorithm must be language-independent
so that the instructions in an algorithm can be implemented in any of
the languages with the same output.
Dataflow of an Algorithm
o Problem: A problem can be a real-world problem or any instance from
the real-world problem for which we need to create a program or the
set of instructions. The set of instructions is known as an algorithm.
o Algorithm: An algorithm will be designed for a problem which is a step
by step procedure.
o Input: After designing an algorithm, the required and the desired inputs
are provided to the algorithm.
o Processing unit: The input will be given to the processing unit, and the
processing unit will produce the desired output.
o Output: The output is the outcome or the result of the program.
Why do we need Algorithms?
We need algorithms because of the following reasons:
Step 2: Squeeze the lemon as much you can and take out its juice in a container.
Step 5: When sugar gets dissolved, add some water and ice in it.
The above real-world can be directly compared to the definition of the algorithm.
We cannot perform the step 3 before the step 2, we need to follow the specific
order to make lemon juice. An algorithm also says that each and every instruction
should be followed in a specific order to perform a specific task.
The following are the steps required to add two numbers entered by the user:
Step 1: Start
Step 6: Stop