SlideShare a Scribd company logo
z
Farzana Shah
(BS-IT, MBA-HRM)
Lecturer : (Computer Science)
Al
orithm
FARZANASHAHICS
1
z
Contents
LECT # 2
Algorithm
 Definition of algorithm
 Need of algorithm
 Designing of algorithm
 Pseudocode
 Examples
2
FARZANASHAHICS
z
ALGORITHMS AND Program
3
A typical programming task can be divided into
two phases:
Problem solving phase
produce an ordered sequence of steps that describe
solution of problem
this sequence of steps is called an algorithm
Implementation phase
implement the program in some programming
language
FARZANASHAHICS
z
Algorithm(noun):
A set of steps to accomplisha task
FARZANASHAHICS
4
z
Analgorithmdescribesthestepby
stepaction to solve a problem.
FARZANASHAHICS
5
z
Analgorithmhasa welldefined
sequenceof steps, it givesyouan
output,andit willeventually
terminate.
1
FARZANASHAHICS
6
z
Analgorithmis a precisestep-by-
stepplanfora computational
procedure that possiblybeginswith
aninput valueandyieldsanoutput
valuein a finite numberofsteps in
orderto solve a particular problem
FARZANASHAHICS
7
z
Analgorithm is a self-containedstep-by-stepset of
operationsto be performedto solve a specific
problemor a class ofproblems.
A computerprogramis a sequence ofinstructions
that complytherulesofa specificprogramming
language , written to performa specifiedtaskwith
a computer.
FARZANASHAHICS
8
z
Algorithms
9
An algorithm is a finite set of steps defining the
solution of a particular problem.
Need not to belong one particular language
Sequence of English statements can also be algorithm
It is not a computer program
An algorithm can be expressed in English like
language, called pseudocode, in a programming
language or in the form of flowchart.
FARZANASHAHICS
z
WhyAlgorithm is needed?
10
Computer Program ?
Set of instructions to perform some specific task
Is Program itself a Software ?
NO, Program is small part of software.
Software merely comprises of Group of Programs
(Source code),
Code: refers to statements that are written in any
programming language as machine code or C code.
•Code is some time interchangeably used with
program.
FARZANASHAHICS
z WhyAlgorithm is needed?FARZANASHAHICS
11
• Programming is both tedious and exciting.
Tedious because like spoken languages
programming languages also have so many
demanding rules.
Exciting because writing program provides the
programmer with the chance to create
something new also gives challenges of solving
a problem.
z WhyAlgorithm is needed?
12
It is very difficult to write direct programs in
any language, just like you can not start
constructing building without the design of
building.
For constructing a building you need design of
building, similarly for writing a large or good
program you need algorithm.
FARZANASHAHICS
z Program design
13
Program Design Process has 2 phases:
Problem Solving Phase
Creates an algorithm that solves the problem
Implementation (Coding) Phase
Translates the algorithm into a programming
language
Algorithm
Problem Program
FARZANASHAHICS
z Algorithm Vs Program
14
What is the difference between an algorithm and a program?
a program is an implementation of an algorithm to be run on a
specific computer and operating system.
an algorithm is more abstract – it does not deal with machine
specific details – think of it as a method to solve a problem.
•What is good algorithm?
Efficient algorithms are good, we generally measure efficiency of
an algorithm on the basis of:
1.Time: algorithm should take minimum time to execute.
2.Space: algorithm should use less memory.
FARZANASHAHICS
z
Algorithm Specification
Every algorithm must satisfy the following
criteria:
Input. Zero or more quantities are externally supplied.
Output. At least one quantity is produced.
Definiteness. Each instruction must be clear and
unambiguous(Unique meaning).
Finiteness. An algorithm terminates in a finite number of steps.
Effectiveness. Every instruction must be basic enough to be carried
out than, means not so complex.
15
FARZANASHAHICS
z Pseudocode
16
 First produce a general algorithm (one can
use pseudo code)
 Refine the algorithm successively to get
step by step detailed algorithm that is very
close to a computer language.
 Pseudo code is an artificial and informal
language that helps programmers develop
algorithms. Pseudo code is very similar to
everyday English.
FARZANASHAHICS
z
DIFFERENCE BETWEEN ALGORITHM
AND PSEUDOCODE?
17
An algorithm is a well defined sequence of steps that
provides a solution for a given problem, while a
pseudocode is one of the methods that can be used to
represent an algorithm.
While algorithms can be written in natural language,
pseudocode is written in a format that is closely related
to high level programming language structures.
FARZANASHAHICS
z
DIFFERENCE BETWEEN ALGORITHM
AND PSEUDOCODE?
18
But pseudocode does not use specific programming
language syntax and therefore could be understood by
programmers who are familiar with different
programming languages.
Additionally, transforming an algorithm presented in
pseudocode to programming code could be much
easier than converting an algorithm written in natural
language.
FARZANASHAHICS
z
Informal definition of an algorithm
19
FARZANASHAHICS
z
ALGORITHM
REPRESENTATION
20
FARZANASHAHICS
z
Example 1
21
Average Of Two numbers
Input: Two numbers
1.Add the two numbers
2.Divide the result by 2
3.Return the result by step 2 2 End
Write an algorithm that reads two numbers and prints
their average.
FARZANASHAHICS
z
Example 2
22
Pass/FailGrade
Input: One number
1.if (the number is greater than or
equal to 40) then
1.Set the grade to “pass” else
2.Set the grade to “fail” End if
2.Return the grade End
Write an algorithm that reads marks number
and prints whether student is pass or fail.
FARZANASHAHICS
z
Example 3
23
Marks range Grade
>=80 A
>=70 &<80 B
>=60 &<70 C
>=50 &<60 D
<50 F
Write an algorithm that read a numbers and prints
the grade of student.
FARZANASHAHICS
z
Algorithm for Grading
AlgoForGrade
Input: One number
1.if (the number is between 80 and 100, inclusive)
then
1. Set the grade to “A” End if
2.if (the number is between 70 and 79, inclusive)
then
1. Set the grade to “B” End if
Continues on the next slide
Solution
24
FARZANASHAHICS
z
3. if (the number is between 60 and 69,
inclusive) then
3.1 Set the grade to “C” End if
4. if (the number is between 50 and 59, inclusive)
then
1. Set the grade to “D” End if
5. If (the number is less than 50) then
1. Set the grade to “F” End if
6. Return the grade End
25
FARZANASHAHICS
z
PSEUDOCODE & ALGORITHM
FARZANASHAHICS
26
 Example : Write an algorithm to determine a student’s final
grade and indicate whether it is passing or failing. The final
grade is calculated as the average of four marks.
EXAMPLE 4
Pseudo code:
Input a set of 4 marks
Calculate their average by summing and
dividing by 4
if average is below 50 Print “FAIL”
else
Print “PASS”
z
 DetailedAlgorithm
Step 1:
Step 2:
Step 3:
Input M1,M2,M3,M4
GRADE (M1+M2+M3+M4)/4
if (GRADE < 50) then Print
“FAIL” else
Print “PASS”
endif
PSEUDOCODE & ALGORITHM
FARZANASHAHICS
27
z
Question &
Answer
Farzana Shah
Lect: Computer Science
FARZANASHAHICS
28

More Related Content

What's hot

memory hierarchy
memory hierarchymemory hierarchy
memory hierarchy
sreelakshmikv
 
Algorithm
AlgorithmAlgorithm
Algorithm
IHTISHAM UL HAQ
 
Memory management
Memory managementMemory management
Memory management
Muhammad Fayyaz
 
Micro operations
Micro operationsMicro operations
Micro operations
Ramakrishna Reddy Bijjam
 
Program control
Program controlProgram control
Program control
Rahul Narang
 
03 algorithm properties
03 algorithm properties03 algorithm properties
03 algorithm propertiesLincoln School
 
Register transfer language
Register transfer languageRegister transfer language
Register transfer language
Sanjeev Patel
 
ALGORITHMS AND FLOWCHARTS
ALGORITHMS AND FLOWCHARTSALGORITHMS AND FLOWCHARTS
ALGORITHMS AND FLOWCHARTS
Kate Campbell
 
Memory management
Memory managementMemory management
Memory management
cpjcollege
 
Our presentation on algorithm design
Our presentation on algorithm designOur presentation on algorithm design
Our presentation on algorithm designNahid Hasan
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
Rabin BK
 
mano.ppt
mano.pptmano.ppt
mano.ppt
prathamgunj
 
Algorithms Lecture 2: Analysis of Algorithms I
Algorithms Lecture 2: Analysis of Algorithms IAlgorithms Lecture 2: Analysis of Algorithms I
Algorithms Lecture 2: Analysis of Algorithms I
Mohamed Loey
 
Discrete Math Presentation(Rules of Inference)
Discrete Math Presentation(Rules of Inference)Discrete Math Presentation(Rules of Inference)
Discrete Math Presentation(Rules of Inference)
Ikhtiar Khan Sohan
 
Introduction to Algorithms & flow charts
Introduction to Algorithms & flow chartsIntroduction to Algorithms & flow charts
Introduction to Algorithms & flow charts
Yash Gupta
 
Agile software development
Agile software developmentAgile software development
Agile software development
Muhammad Amjad Rana
 
Types of instructions
Types of instructionsTypes of instructions
Types of instructions
ihsanjamil
 
Computer architecture pipelining
Computer architecture pipeliningComputer architecture pipelining
Computer architecture pipelining
Mazin Alwaaly
 
Pipelining powerpoint presentation
Pipelining powerpoint presentationPipelining powerpoint presentation
Pipelining powerpoint presentation
bhavanadonthi
 

What's hot (20)

memory hierarchy
memory hierarchymemory hierarchy
memory hierarchy
 
Algorithm
AlgorithmAlgorithm
Algorithm
 
Memory management
Memory managementMemory management
Memory management
 
Micro operations
Micro operationsMicro operations
Micro operations
 
Program control
Program controlProgram control
Program control
 
03 algorithm properties
03 algorithm properties03 algorithm properties
03 algorithm properties
 
Register transfer language
Register transfer languageRegister transfer language
Register transfer language
 
ALGORITHMS AND FLOWCHARTS
ALGORITHMS AND FLOWCHARTSALGORITHMS AND FLOWCHARTS
ALGORITHMS AND FLOWCHARTS
 
Memory management
Memory managementMemory management
Memory management
 
Our presentation on algorithm design
Our presentation on algorithm designOur presentation on algorithm design
Our presentation on algorithm design
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
 
mano.ppt
mano.pptmano.ppt
mano.ppt
 
Algorithms Lecture 2: Analysis of Algorithms I
Algorithms Lecture 2: Analysis of Algorithms IAlgorithms Lecture 2: Analysis of Algorithms I
Algorithms Lecture 2: Analysis of Algorithms I
 
Discrete Math Presentation(Rules of Inference)
Discrete Math Presentation(Rules of Inference)Discrete Math Presentation(Rules of Inference)
Discrete Math Presentation(Rules of Inference)
 
Introduction to Algorithms & flow charts
Introduction to Algorithms & flow chartsIntroduction to Algorithms & flow charts
Introduction to Algorithms & flow charts
 
Agile software development
Agile software developmentAgile software development
Agile software development
 
Daa
DaaDaa
Daa
 
Types of instructions
Types of instructionsTypes of instructions
Types of instructions
 
Computer architecture pipelining
Computer architecture pipeliningComputer architecture pipelining
Computer architecture pipelining
 
Pipelining powerpoint presentation
Pipelining powerpoint presentationPipelining powerpoint presentation
Pipelining powerpoint presentation
 

Similar to Algorithm

3 algorithm-and-flowchart
3 algorithm-and-flowchart3 algorithm-and-flowchart
3 algorithm-and-flowchart
Rohit Shrivastava
 
ALGORITHM PPT GUIDE.pdf
ALGORITHM PPT GUIDE.pdfALGORITHM PPT GUIDE.pdf
ALGORITHM PPT GUIDE.pdf
meychu1
 
Algorithm and pseudo codes
Algorithm and pseudo codesAlgorithm and pseudo codes
Algorithm and pseudo codeshermiraguilar
 
Introduction to computer science
Introduction to computer scienceIntroduction to computer science
Introduction to computer science
umardanjumamaiwada
 
lecture 5
 lecture 5 lecture 5
lecture 5
umardanjumamaiwada
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
Sachin Goyani
 
Lec 2 -algorithms-flowchart-and-pseudocode1.pptx
Lec 2 -algorithms-flowchart-and-pseudocode1.pptxLec 2 -algorithms-flowchart-and-pseudocode1.pptx
Lec 2 -algorithms-flowchart-and-pseudocode1.pptx
AbdelrahmanRagab36
 
Ic lecture7
Ic lecture7  Ic lecture7
Ic lecture7
AttaullahRahimoon
 
Fundamentals of programming with C++
Fundamentals of programming with C++Fundamentals of programming with C++
Fundamentals of programming with C++
Seble Nigussie
 
Algorithm Design & Implementation
Algorithm Design & ImplementationAlgorithm Design & Implementation
Algorithm Design & Implementation
Gaditek
 
PCCF UNIT 1.pptx
PCCF UNIT 1.pptxPCCF UNIT 1.pptx
PCCF UNIT 1.pptx
DivyaKS12
 
What is algorithm
What is algorithmWhat is algorithm
What is algorithm
mshoaib15
 
Algorithms and flow charts
Algorithms and flow chartsAlgorithms and flow charts
Algorithms and flow charts
Chinnu Edwin
 
C programming .pptx
C programming .pptxC programming .pptx
C programming .pptx
SuhaibKhan62
 
Basic Computer Programming
Basic Computer ProgrammingBasic Computer Programming
Basic Computer Programming
Allen de Castro
 
Fundamentals of Programming Lecture #1.pptx
Fundamentals of Programming Lecture #1.pptxFundamentals of Programming Lecture #1.pptx
Fundamentals of Programming Lecture #1.pptx
Eyasu46
 
program development and paradigms
program development and paradigmsprogram development and paradigms
program development and paradigms
kasenerd
 
02 Algorithms and flowcharts - computers.pptx
02 Algorithms and flowcharts - computers.pptx02 Algorithms and flowcharts - computers.pptx
02 Algorithms and flowcharts - computers.pptx
arifaqazi2
 
Introduction to programming c
Introduction to programming cIntroduction to programming c
Introduction to programming c
Md. Rakibuzzaman Khan Pathan
 
Lesson 1 - Introduction to Computer Programming.pptx
Lesson 1 - Introduction to Computer Programming.pptxLesson 1 - Introduction to Computer Programming.pptx
Lesson 1 - Introduction to Computer Programming.pptx
Neil Mutia
 

Similar to Algorithm (20)

3 algorithm-and-flowchart
3 algorithm-and-flowchart3 algorithm-and-flowchart
3 algorithm-and-flowchart
 
ALGORITHM PPT GUIDE.pdf
ALGORITHM PPT GUIDE.pdfALGORITHM PPT GUIDE.pdf
ALGORITHM PPT GUIDE.pdf
 
Algorithm and pseudo codes
Algorithm and pseudo codesAlgorithm and pseudo codes
Algorithm and pseudo codes
 
Introduction to computer science
Introduction to computer scienceIntroduction to computer science
Introduction to computer science
 
lecture 5
 lecture 5 lecture 5
lecture 5
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
 
Lec 2 -algorithms-flowchart-and-pseudocode1.pptx
Lec 2 -algorithms-flowchart-and-pseudocode1.pptxLec 2 -algorithms-flowchart-and-pseudocode1.pptx
Lec 2 -algorithms-flowchart-and-pseudocode1.pptx
 
Ic lecture7
Ic lecture7  Ic lecture7
Ic lecture7
 
Fundamentals of programming with C++
Fundamentals of programming with C++Fundamentals of programming with C++
Fundamentals of programming with C++
 
Algorithm Design & Implementation
Algorithm Design & ImplementationAlgorithm Design & Implementation
Algorithm Design & Implementation
 
PCCF UNIT 1.pptx
PCCF UNIT 1.pptxPCCF UNIT 1.pptx
PCCF UNIT 1.pptx
 
What is algorithm
What is algorithmWhat is algorithm
What is algorithm
 
Algorithms and flow charts
Algorithms and flow chartsAlgorithms and flow charts
Algorithms and flow charts
 
C programming .pptx
C programming .pptxC programming .pptx
C programming .pptx
 
Basic Computer Programming
Basic Computer ProgrammingBasic Computer Programming
Basic Computer Programming
 
Fundamentals of Programming Lecture #1.pptx
Fundamentals of Programming Lecture #1.pptxFundamentals of Programming Lecture #1.pptx
Fundamentals of Programming Lecture #1.pptx
 
program development and paradigms
program development and paradigmsprogram development and paradigms
program development and paradigms
 
02 Algorithms and flowcharts - computers.pptx
02 Algorithms and flowcharts - computers.pptx02 Algorithms and flowcharts - computers.pptx
02 Algorithms and flowcharts - computers.pptx
 
Introduction to programming c
Introduction to programming cIntroduction to programming c
Introduction to programming c
 
Lesson 1 - Introduction to Computer Programming.pptx
Lesson 1 - Introduction to Computer Programming.pptxLesson 1 - Introduction to Computer Programming.pptx
Lesson 1 - Introduction to Computer Programming.pptx
 

More from farishah

INTRODUCTION TO HARDWARE
INTRODUCTION TO HARDWAREINTRODUCTION TO HARDWARE
INTRODUCTION TO HARDWARE
farishah
 
Introduction to computer
Introduction to computerIntroduction to computer
Introduction to computer
farishah
 
Computer applications to business
Computer applications to businessComputer applications to business
Computer applications to business
farishah
 
Types of software
Types of softwareTypes of software
Types of software
farishah
 
Introduction of c language
Introduction of c languageIntroduction of c language
Introduction of c language
farishah
 
Letter writing essentials
Letter writing essentialsLetter writing essentials
Letter writing essentials
farishah
 

More from farishah (6)

INTRODUCTION TO HARDWARE
INTRODUCTION TO HARDWAREINTRODUCTION TO HARDWARE
INTRODUCTION TO HARDWARE
 
Introduction to computer
Introduction to computerIntroduction to computer
Introduction to computer
 
Computer applications to business
Computer applications to businessComputer applications to business
Computer applications to business
 
Types of software
Types of softwareTypes of software
Types of software
 
Introduction of c language
Introduction of c languageIntroduction of c language
Introduction of c language
 
Letter writing essentials
Letter writing essentialsLetter writing essentials
Letter writing essentials
 

Recently uploaded

Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
Celine George
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
Celine George
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
Nguyen Thanh Tu Collection
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
PedroFerreira53928
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 

Recently uploaded (20)

Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 

Algorithm

  • 1. z Farzana Shah (BS-IT, MBA-HRM) Lecturer : (Computer Science) Al orithm FARZANASHAHICS 1
  • 2. z Contents LECT # 2 Algorithm  Definition of algorithm  Need of algorithm  Designing of algorithm  Pseudocode  Examples 2 FARZANASHAHICS
  • 3. z ALGORITHMS AND Program 3 A typical programming task can be divided into two phases: Problem solving phase produce an ordered sequence of steps that describe solution of problem this sequence of steps is called an algorithm Implementation phase implement the program in some programming language FARZANASHAHICS
  • 4. z Algorithm(noun): A set of steps to accomplisha task FARZANASHAHICS 4
  • 6. z Analgorithmhasa welldefined sequenceof steps, it givesyouan output,andit willeventually terminate. 1 FARZANASHAHICS 6
  • 7. z Analgorithmis a precisestep-by- stepplanfora computational procedure that possiblybeginswith aninput valueandyieldsanoutput valuein a finite numberofsteps in orderto solve a particular problem FARZANASHAHICS 7
  • 8. z Analgorithm is a self-containedstep-by-stepset of operationsto be performedto solve a specific problemor a class ofproblems. A computerprogramis a sequence ofinstructions that complytherulesofa specificprogramming language , written to performa specifiedtaskwith a computer. FARZANASHAHICS 8
  • 9. z Algorithms 9 An algorithm is a finite set of steps defining the solution of a particular problem. Need not to belong one particular language Sequence of English statements can also be algorithm It is not a computer program An algorithm can be expressed in English like language, called pseudocode, in a programming language or in the form of flowchart. FARZANASHAHICS
  • 10. z WhyAlgorithm is needed? 10 Computer Program ? Set of instructions to perform some specific task Is Program itself a Software ? NO, Program is small part of software. Software merely comprises of Group of Programs (Source code), Code: refers to statements that are written in any programming language as machine code or C code. •Code is some time interchangeably used with program. FARZANASHAHICS
  • 11. z WhyAlgorithm is needed?FARZANASHAHICS 11 • Programming is both tedious and exciting. Tedious because like spoken languages programming languages also have so many demanding rules. Exciting because writing program provides the programmer with the chance to create something new also gives challenges of solving a problem.
  • 12. z WhyAlgorithm is needed? 12 It is very difficult to write direct programs in any language, just like you can not start constructing building without the design of building. For constructing a building you need design of building, similarly for writing a large or good program you need algorithm. FARZANASHAHICS
  • 13. z Program design 13 Program Design Process has 2 phases: Problem Solving Phase Creates an algorithm that solves the problem Implementation (Coding) Phase Translates the algorithm into a programming language Algorithm Problem Program FARZANASHAHICS
  • 14. z Algorithm Vs Program 14 What is the difference between an algorithm and a program? a program is an implementation of an algorithm to be run on a specific computer and operating system. an algorithm is more abstract – it does not deal with machine specific details – think of it as a method to solve a problem. •What is good algorithm? Efficient algorithms are good, we generally measure efficiency of an algorithm on the basis of: 1.Time: algorithm should take minimum time to execute. 2.Space: algorithm should use less memory. FARZANASHAHICS
  • 15. z Algorithm Specification Every algorithm must satisfy the following criteria: Input. Zero or more quantities are externally supplied. Output. At least one quantity is produced. Definiteness. Each instruction must be clear and unambiguous(Unique meaning). Finiteness. An algorithm terminates in a finite number of steps. Effectiveness. Every instruction must be basic enough to be carried out than, means not so complex. 15 FARZANASHAHICS
  • 16. z Pseudocode 16  First produce a general algorithm (one can use pseudo code)  Refine the algorithm successively to get step by step detailed algorithm that is very close to a computer language.  Pseudo code is an artificial and informal language that helps programmers develop algorithms. Pseudo code is very similar to everyday English. FARZANASHAHICS
  • 17. z DIFFERENCE BETWEEN ALGORITHM AND PSEUDOCODE? 17 An algorithm is a well defined sequence of steps that provides a solution for a given problem, while a pseudocode is one of the methods that can be used to represent an algorithm. While algorithms can be written in natural language, pseudocode is written in a format that is closely related to high level programming language structures. FARZANASHAHICS
  • 18. z DIFFERENCE BETWEEN ALGORITHM AND PSEUDOCODE? 18 But pseudocode does not use specific programming language syntax and therefore could be understood by programmers who are familiar with different programming languages. Additionally, transforming an algorithm presented in pseudocode to programming code could be much easier than converting an algorithm written in natural language. FARZANASHAHICS
  • 19. z Informal definition of an algorithm 19 FARZANASHAHICS
  • 21. z Example 1 21 Average Of Two numbers Input: Two numbers 1.Add the two numbers 2.Divide the result by 2 3.Return the result by step 2 2 End Write an algorithm that reads two numbers and prints their average. FARZANASHAHICS
  • 22. z Example 2 22 Pass/FailGrade Input: One number 1.if (the number is greater than or equal to 40) then 1.Set the grade to “pass” else 2.Set the grade to “fail” End if 2.Return the grade End Write an algorithm that reads marks number and prints whether student is pass or fail. FARZANASHAHICS
  • 23. z Example 3 23 Marks range Grade >=80 A >=70 &<80 B >=60 &<70 C >=50 &<60 D <50 F Write an algorithm that read a numbers and prints the grade of student. FARZANASHAHICS
  • 24. z Algorithm for Grading AlgoForGrade Input: One number 1.if (the number is between 80 and 100, inclusive) then 1. Set the grade to “A” End if 2.if (the number is between 70 and 79, inclusive) then 1. Set the grade to “B” End if Continues on the next slide Solution 24 FARZANASHAHICS
  • 25. z 3. if (the number is between 60 and 69, inclusive) then 3.1 Set the grade to “C” End if 4. if (the number is between 50 and 59, inclusive) then 1. Set the grade to “D” End if 5. If (the number is less than 50) then 1. Set the grade to “F” End if 6. Return the grade End 25 FARZANASHAHICS
  • 26. z PSEUDOCODE & ALGORITHM FARZANASHAHICS 26  Example : Write an algorithm to determine a student’s final grade and indicate whether it is passing or failing. The final grade is calculated as the average of four marks. EXAMPLE 4 Pseudo code: Input a set of 4 marks Calculate their average by summing and dividing by 4 if average is below 50 Print “FAIL” else Print “PASS”
  • 27. z  DetailedAlgorithm Step 1: Step 2: Step 3: Input M1,M2,M3,M4 GRADE (M1+M2+M3+M4)/4 if (GRADE < 50) then Print “FAIL” else Print “PASS” endif PSEUDOCODE & ALGORITHM FARZANASHAHICS 27
  • 28. z Question & Answer Farzana Shah Lect: Computer Science FARZANASHAHICS 28