Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
3 views

What is an Algorithm

An algorithm is a set of rules or instructions for performing calculations or problem-solving, characterized by input, output, unambiguity, finiteness, effectiveness, and language independence. Algorithms are essential for breaking down complex problems into manageable steps and can be represented through flowcharts or pseudocode. The document provides examples of algorithms, including a real-world scenario of making lemon juice and a programming example for adding two numbers.

Uploaded by

deena
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

What is an Algorithm

An algorithm is a set of rules or instructions for performing calculations or problem-solving, characterized by input, output, unambiguity, finiteness, effectiveness, and language independence. Algorithms are essential for breaking down complex problems into manageable steps and can be represented through flowcharts or pseudocode. The document provides examples of algorithms, including a real-world scenario of making lemon juice and a programming example for adding two numbers.

Uploaded by

deena
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

What is an Algorithm?

An algorithm is a process or a set of rules required to perform calculations or some


other problem-solving operations especially by a computer. The formal definition
of an algorithm is that it contains the finite set of instructions which are being
carried in a specific order to perform the specific task. It is not the complete
program or code; it is just a solution (logic) of a problem, which can be
represented either as an informal description using a Flowchart or Pseudocode.

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:

o Scalability: It helps us to understand the scalability. When we have a big


real-world problem, we need to scale it down into small-small steps to
easily analyze the problem.
o Performance: The real-world is not easily broken down into smaller
steps. If the problem can be easily broken into smaller steps means that
the problem is feasible.
Let's understand the algorithm through a real-world example. Suppose we want
to make a lemon juice, so following are the steps required to make a lemon juice:

Step 1: First, we will cut the lemon into half.

Step 2: Squeeze the lemon as much you can and take out its juice in a container.

Step 3: Add two tablespoon sugar in it.

Step 4: Stir the container until the sugar gets dissolved.

Step 5: When sugar gets dissolved, add some water and ice in it.

Step 6: Store the juice in a fridge for 5 to minutes.

Step 7: Now, it's ready to drink.

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.

Now we will look an example of an algorithm in programming.

We will write an algorithm to add two numbers entered by the user.

The following are the steps required to add two numbers entered by the user:

Step 1: Start

Step 2: Declare three variables a, b, and sum.

Step 3: Enter the values of a and b.


Step 4: Add the values of a and b and store the result in the sum variable, i.e.,
sum=a+b.

Step 5: Print sum

Step 6: Stop

You might also like