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

Lecture 2

This document discusses algorithms and their properties. It defines an algorithm as a finite sequence of unambiguous steps to solve a problem in a finite amount of time. The key properties of algorithms are that they take input, produce output, are definite, correct, and terminate in a finite number of steps. Algorithms can be represented through pseudocode or flowcharts. Examples are given of algorithms to add three numbers and find the largest of three numbers. Algorithms are important because they allow problems to be solved systematically and independently of hardware or software.
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)
20 views

Lecture 2

This document discusses algorithms and their properties. It defines an algorithm as a finite sequence of unambiguous steps to solve a problem in a finite amount of time. The key properties of algorithms are that they take input, produce output, are definite, correct, and terminate in a finite number of steps. Algorithms can be represented through pseudocode or flowcharts. Examples are given of algorithms to add three numbers and find the largest of three numbers. Algorithms are important because they allow problems to be solved systematically and independently of hardware or software.
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/ 14

Algorithm

Dr. Priyakshi Mahanta


Assistant Professor
CCSA, Dibrugarh University
Algorithm in real life(to bake a
cake)
What is a Algorithm ?

 a step‐by‐step problem solving process in which a solution is


arrived in a finite amount of time
 finite sequence of unambiguous steps or instructions,
which, if followed would ultimately terminate and give the
solution of the problem

3
Properties of algorithms
 Input: what the algorithm takes in as input
 Output: what the algorithm produces as output
 Definiteness/unambigious
Read
Read a,b
 Correctness
 Finiteness: while(1)
{-------
}
 Effectiveness:
Start
Read a,b
Read c
Sum=a+b
Print sum
End

4
Why algorithm?

5
Algorithm and programs

• Algorithms:
– use natural language
– written by domain expert
– Software and hardware independent
– Analyze algorithms
6
Algorithm representation
 Pseudo code

 Flowchart

7
ALGORITHM TO FIND THE AREA OF A RECTANGLE
How to write a algorithm
 The problem that is to be  Add 3 numbers and print
solved their sum.
 The numbers must
 The constraints of the contain only digits and
problem no other characters
 The input to be taken  The three numbers to be
added.
 The output to be expected  The sum of the three
 The solution to this problem numbers taken as the
output.
 The solution consists of
adding the 3 numbers. It
can be done with the help
of ‘+’ operator, or bit-wise
Algorithm to add three numbers
• Start
• Get input
Read num1 num2 num3
• Calculate sum
sum = num1 + num2+num 3
• Display output
• Print sum
• End
ALGORITHM TO FIND THE LARGEST OF
THREE NUMBERS
ALGORITHM TO FIND THE LARGEST OF
THREE NUMBERS
 References

1)https://depositphotos.com/27462911/sto
ck-photo-flow-chart-diagram.html
2)https://www.geeksforgeeks.org/introduct
ion-to-algorithms/
3) https://en.wikipedia.org/wiki/Algorithm
Thank You

You might also like