0% found this document useful (0 votes)
43 views

L2 - Algorithm For Problem Solving

This document discusses algorithms and their characteristics. It defines an algorithm as a finite sequence of instructions to solve a problem or perform a computation. An algorithm must be unambiguous, have well-defined inputs and outputs, terminate in a finite number of steps, and be feasible with available resources. It also discusses qualities of good algorithms like time and memory efficiency. The document presents different representations of algorithms like English language, flowcharts, and pseudo-code. It provides examples of algorithms in English to add two integers and find the maximum of three numbers.

Uploaded by

pnsp.243
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)
43 views

L2 - Algorithm For Problem Solving

This document discusses algorithms and their characteristics. It defines an algorithm as a finite sequence of instructions to solve a problem or perform a computation. An algorithm must be unambiguous, have well-defined inputs and outputs, terminate in a finite number of steps, and be feasible with available resources. It also discusses qualities of good algorithms like time and memory efficiency. The document presents different representations of algorithms like English language, flowcharts, and pseudo-code. It provides examples of algorithms in English to add two integers and find the maximum of three numbers.

Uploaded by

pnsp.243
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/ 9

CSE1011: Fundamentals of Computer Science

(FoCS)

L-02: Algorithm for problem solving

Dr. Sanjeev Kumar Dwivedi


EMP ID: 70605
VIT-AP School of Computer Science and Engineering (SCOPE)
VIT-AP University
Definition of an Algorithm:
• An algorithm is a finite sequence of well-defined, computer-implementable
instructions, typically to solve a class of specific problems or to perform a
computation.

• The sequence of instructions designed in such a way that if the instructions are
executed in the specified sequence, the desired results will be obtained.

• The algorithm should precise and unambiguous in practice and the results should
obtain after a finite number of steps.

2
Characteristics of an algorithm:
• Unambiguous: Algorithm should be clear and unambiguous. Each of its steps (or
phases), and their inputs/outputs should be clear and must lead to only one
meaning.
• Input: An algorithm should have 0 or more well-defined inputs.
• Output: An algorithm should have 1 or more well-defined outputs, and should
match the desired output.
• Finiteness: Algorithms must terminate after a finite number of steps.
• Feasibility: Should be feasible with the available resources.
• Independent: An algorithm should have step-by-step directions, which should be
independent of any programming code.
3
Qualities of a good algorithm: The various factors that can be used to judge
the quality of an algorithm are-

• Time.
• Memory.
• Accuracy.
• Sequence.
• Generalized.

=--=-=-=-=--=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=--=-=-=-=-=--=-=--=-=-=--=-=-=--=-=-=-=-

❖ Think about Time vs Memory concept used in computer science?

4
Representation of Algorithms:

• English Language: The algorithm can be easily represented in step by step


sequential order in normal English, such algorithms are easy to understand,
write and read.

• Flow Chart: The flowchart is a pictorial representation of algorithms, the


sequential steps in an algorithm can be represented as a flowchart using the
standard symbols.

• Pseudo Code: Pseudo code is a formal design tools and is very well with the
rules of structured design and programming.

5
Algorithm for adding two integers using normal English language:

Step 1: START
Step 2: Declare three integers num1, num2 & sum
Step 3: Define values of num1 & num2
Step 4: Add values of num1 & num2
Step 5: Store output of step 4 to sum
Step 6: Display the output
Step 7: STOP

=--=-=-=-=--=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=--=-=-=-=-=--=-=--=-=-=--=-=--=-=-=-==-=
❖ Think about pre-defined values and run-time values?
6
Algorithm for finding the maximum of three positive numbers using
normal English language:

Step 1: START
Step 2: Declare three integers num1, num2 & num3
Step 3: Check if A is greater than B and C, A is the largest number
Step 4: Check if B is greater than A and C, B is the largest number
Step 5: Check if C is greater than A and B, C is the largest number
Step 6: STOP

7
Q. write an algorithm for finding the average of three numbers?

Q. Write an algorithm to calculate and print the total number of students selected
in various group, using the following criteria. In a school there are 100 student
appeared for examination. Based upon the student marks who secure greater
than 70% as first class, greater than 60% as second class, and greater than 50% as
third class and remaining are fail.

8
Thank You

You might also like