0% found this document useful (0 votes)
22 views17 pages

Problem Solving

The document defines and explains algorithms. An algorithm is a set of steps to solve a problem or complete a task. It must be finite, effective, language independent, and scalable. The document provides examples of algorithms to make lemon juice and add two numbers. It also explains the components of a flowchart, which is a graphical representation of an algorithm using symbols like rectangles, diamonds, and arrows. Flowcharts help communicate an algorithm's logic and guide coding.

Uploaded by

akubabybackg
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views17 pages

Problem Solving

The document defines and explains algorithms. An algorithm is a set of steps to solve a problem or complete a task. It must be finite, effective, language independent, and scalable. The document provides examples of algorithms to make lemon juice and add two numbers. It also explains the components of a flowchart, which is a graphical representation of an algorithm using symbols like rectangles, diamonds, and arrows. Flowcharts help communicate an algorithm's logic and guide coding.

Uploaded by

akubabybackg
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Algorithm

Prepared By: Suraj Prajapati


 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.
 Input: An algorithm has some input values.
We can pass 0 or some input value to an
algorithm.
 Output: We will get 1 or more output at the
end of an algorithm.
 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.
 Effectiveness: An algorithm should be
effective as each instruction in an algorithm
affects the overall process.
 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
 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.
 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.
Now we will look an example of an algorithm in
programming.
We will write an algorithm 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, sum=a+b.
 Step 5: Print sum

 Step 6: Stop
 The Flowchart is the most widely used
graphical representation of an algorithm and
procedural design workflows.
 It uses various symbols to show the operations
and decisions to be followed in a program. It
flows in sequential order.
 Flowchart is graphical or pictorial
representation of any program.
 Terminal Symbol: in the flowchart, it is
represented with the help of a circle for
denoting the start and stop symbol.

 Input/output Symbol: The input symbol is


used to represent the input data, and the
output symbol is used to display the output
operation
Processing Symbol:It is represented in a
flowchart with the help of a rectangle box used to
represent the arithmetic and data movement
instructions.
Diamond symbol is used for represents decision-
making statements. The symbol given below is
used to represent the decision symbol.
The connector symbol is used if flows
discontinued at some point and continued again
at another place. The following symbol is the
representation of the connector symbol.
It represents the exact sequence in which
instructions are executed. Arrows are used to
represent. the flow lines in a flowchart.
 Communication: A flowchart is a better way of
communicating the logic of a program.
 Efficient Coding: Flowcharts act as a guide for a
programmer in writing the actual code in a high-
level language.
 Synthesis: Flowchart is used as working models
in designing new programs and software systems.
 Proper Documentation: Flowchart provides better
and proper documentation. It consists of various
activities such as collecting, organizing, storing,
and maintaining all related program records.
Thank You !

You might also like