SlideShare a Scribd company logo
1 of 20
UCSE010 - DESIGN AND ANALYSIS OF ALGORITHMS
1
Dr.Nisha Soms/SRIT
Semester-06/2020-2021
Why study Algorithm?
 It is important for all other branches of
computer science
 Plays a key role in modern technological
innovation
 As a developer, our everyday work is to
solve problems and algorithms solve
problems very efficiently.
 Practicing algorithms will increase your
skill and your visibility at work thereby
building a strong foundation in logical
thinking and problem solving
2
When we use Algorithmic Thinking, we direct our behaviours to
specific situations and in the direction of future events.
Dr.Nisha Soms/SRIT
How do algorithms shape our world?
 Google's PageRank algorithm determines how
pages on the internet are displayed and ranked
based on their relevance to your search.
 Sites such as Amazon and Netflix base
recommendations on Collaborative Filtering
algorithms that look at other uses with similar
interests and tastes and subsequently deliver
predictions for purchases and shows.
 Mapping applications such as Google Maps need
to calculate routes through cities, taking into
account distance, traffic, and accidents.
Dijkstra's algorithm, helps us to find these
optimal paths.
3
Dr.Nisha Soms/SRIT
What is an Algorithm?
 A finite set of instructions that
specifies a sequence of operation
 These instructions are carried out
to solve a specific problem or
class of problems
4
All algorithms are essentially detailed sets of instructions that
computers follow to arrive at an answer. Humans also
constantly utilize (simpler) algorithms: for example, a recipe to
make dinner is an algorithm.
Dr.Nisha Soms/SRIT
5
 Formal Definition: An algorithm is a sequence of
unambiguous instructions for solving a problem,
i.e., for obtaining a required output for any legitimate
input in a finite amount of time.
Semester-06/2020-2021 Dr.Nisha Soms/SRIT
Ref:
Introduction to the
Design and Analysis of
Algorithms (3rd ed.),
Anany Levitin
6
An algorithm
Takes the input and transforms it into an adequate output.
The range of inputs for which an algorithm works has to be
specified carefully.
Must be independent from any programming languages
The non-ambiguity requirement for each step of an algorithm
cannot be compromised.
The same algorithm can be represented in several different ways.
There may exist several algorithms for solving the same problem.
Algorithms for the same problem can be based on very different
ideas and can solve the problem with dramatically different speeds.
Semester-06/2020-2021 Dr.Nisha Soms/SRIT
7
METHOD I - Euclid’s
algorithm
METHOD II - Consecutive
integer checking algorithm
METHOD III - Middle-
school procedure
Step 1 If n = 0, return the value
of m as the answer and stop;
otherwise,
proceed to Step 2.
Step 2 Divide m by n and
assign the value of the
remainder to r.
Step 3 Assign the value of n to
m and the value of r to n. Go to
Step 1.
Step 1 Assign the value of
min{m, n} to t.
Step 2 Divide m by t. If the
remainder of this division is 0,
go to Step 3; otherwise, go to
Step 4.
Step 3 Divide n by t. If the
remainder of this division is 0,
return the value of t as the
answer and stop; otherwise,
proceed to Step 4.
Step 4 Decrease the value of t
by 1. Go to Step 2.
Step 1 Find the prime factors
of m.
Step 2 Find the prime factors
of n.
Step 3 Identify all the common
factors in the two prime
expansions found in
Step 4 Compute the product of
all the common factors and
return it as the greatest
common divisor of the
numbers given.
gcd(60, 24) = gcd(24, 12) =
gcd(12, 0) = 12
For numbers 60 and 24, the
algorithm will try first 24, then
23, and so on, until it reaches
12, where it stops.
60 = 2 . 2 . 3 . 5
24 = 2 . 2 . 2 . 3
gcd(60, 24) = 2 . 2 . 3 = 12.
Semester-06/2020-2021 Dr.Nisha Soms/SRIT
8
To allow a successful execution of programs,
algorithms should possess certain qualities. They are:
1. Correctness: if the input conditions are satisfied
and the algorithm instructions are executed, then
correct output is produced.
2. Termination: the algorithm must terminate after a
finite number of steps. This can be ensured if there
are no infinite loops.
3. Performance: Quantification of space and time
complexities.
Semester-06/2020-2021 Dr.Nisha Soms/SRIT
Semester-06/2020-2021 Dr.Nisha Soms/SRIT 9
Ref:
Introduction to the
Design and Analysis of
Algorithms (3rd ed.),
Anany Levitin
1
0
1. From a practical perspective, the first thing you need to do
before designing an algorithm is to understand completely the
problem given.
▪Read the problem’s description carefully and ask questions if you have any
doubts about the problem
2. An input to an algorithm specifies an instance of the problem,
the algorithm solves. It is very important to specify exactly the
set of instances the algorithm needs to handle.
â–ŞIf you fail to do this, your algorithm may work correctly for a majority of inputs
but crash on some “boundary” value. Remember that a correct algorithm is not
one that works most of the time, but one that works correctly for all legitimate
inputs.
3. Do not skimp on this first step of the algorithmic problem-
solving process; otherwise, you will run the risk of unnecessary
rework.
Semester-06/2020-2021 Dr.Nisha Soms/SRIT
1
1
 Once you completely understand a problem, you need to
ascertain the capabilities of the computational device the
algorithm is intended for.
 The vast majority of algorithms in use today are still destined
to be programmed for a computer closely resembling the von
Neumann machine
Semester-06/2020-2021 Dr.Nisha Soms/SRIT
1
2
 The next principal decision is to choose between solving
the problem exactly (known as exact algorithm ) or
solving it approximately (known as approximation
algorithm)
 Why would one opt for an approximation algorithm?
 First, there are important problems that simply cannot be solved
exactly for most of their instances; examples include extracting
square roots, solving nonlinear equations, and evaluating definite
integrals.
 Second, available algorithms for solving a problem exactly can be
unacceptably slow because of the problem’s intrinsic complexity.
 Third, an approximation algorithm can be a part of a more
sophisticated algorithm that solves a problem exactly.
Semester-06/2020-2021 Dr.Nisha Soms/SRIT
1
3
 An algorithm design technique (or “strategy” or
“paradigm”) is a general approach to solving problems
algorithmically that is applicable to a variety of problems
from different areas of computing.
 Learning these techniques is of utmost importance for
the following reasons:
 First, they provide guidance for designing algorithms for new
problems, i.e., problems for which there is no known satisfactory
algorithm.
 Second, Algorithm design techniques make it possible to classify
algorithms according to an underlying design idea; therefore, they
can serve as a natural way to both categorize and study algorithms
Semester-06/2020-2021 Dr.Nisha Soms/SRIT
1
4
 Pseudocode is a mixture of a natural language and
programming language like constructs.
 Pseudocode is usually more precise than natural language, and
its usage often yields more concise algorithm descriptions.
 In the earlier days of computing, the dominant vehicle for
specifying algorithms was a flowchart, a method of expressing
an algorithm by a collection of connected geometric shapes
containing descriptions of the algorithm’s steps.
 This representation technique has proved to be inconvenient for all
but very simple algorithms; nowadays, it can be found only in old
algorithm books.
Semester-06/2020-2021 Dr.Nisha Soms/SRIT
1
5
 A common technique for proving correctness is to use
mathematical induction because an algorithm’s iterations
provide a natural sequence of steps needed for such proofs.
 To show that an algorithm is incorrect, you need just one
instance of its input for which the algorithm fails.
Semester-06/2020-2021 Dr.Nisha Soms/SRIT
1
6
There are two kinds of algorithm efficiency:
â–Ş time efficiency, indicating how fast the algorithm
runs, and
â–Ş space efficiency, indicating how much extra memory it
uses.
 Another desirable characteristic of an algorithm is
simplicity.
â–Ş Because simpler algorithms are easier to understand and
easier to program;
Another desirable characteristic of an algorithm is
generality.
Semester-06/2020-2021 Dr.Nisha Soms/SRIT
1
7
Most algorithms are destined to be ultimately
implemented as computer programs.
A working program provides an additional
opportunity in allowing an empirical analysis of the
underlying algorithm.
Such an analysis is based on timing the program on
several inputs and then analyzing the results obtained
Semester-06/2020-2021 Dr.Nisha Soms/SRIT
 Sorting
 Searching
 String processing
 Graph problems
 Combinatorial problems
 Geometric problems
 Numerical problems
Semester-06/2020-2021 Dr.Nisha Soms/SRIT 18
 https://www.cse.iitd.ac.in/~mausam/courses/c
ol106/autumn2017/lectures/02-asymptotic.pdf
 https://www.coursehero.com/file/51912947/L0
1-Introppt/
 https://anh.cs.luc.edu › notes
 Introduction to the Design and Analysis of
Algorithms (3rd ed.), Anany Levitin
Semester-06/2020-2021 Dr.Nisha Soms/SRIT 19
Please Click Like, Share and Subscribe !
Semester-06/2020-2021 Dr.Nisha Soms/SRIT 20

More Related Content

What's hot

Algorithmic problem solving
Algorithmic problem solvingAlgorithmic problem solving
Algorithmic problem solvingPrabhakaran V M
 
Ai lecture 01(unit03)
Ai lecture  01(unit03)Ai lecture  01(unit03)
Ai lecture 01(unit03)vikas dhakane
 
Matrix chain multiplication
Matrix chain multiplicationMatrix chain multiplication
Matrix chain multiplicationRespa Peter
 
Compiler Design
Compiler DesignCompiler Design
Compiler DesignMir Majid
 
Introduction to Compiler design
Introduction to Compiler design Introduction to Compiler design
Introduction to Compiler design Dr. C.V. Suresh Babu
 
Design and analysis of algorithms
Design and analysis of algorithmsDesign and analysis of algorithms
Design and analysis of algorithmsDr Geetha Mohan
 
Time and space complexity
Time and space complexityTime and space complexity
Time and space complexityAnkit Katiyar
 
Introduction to data structures and Algorithm
Introduction to data structures and AlgorithmIntroduction to data structures and Algorithm
Introduction to data structures and AlgorithmDhaval Kaneria
 
Mathematical Analysis of Non-Recursive Algorithm.
Mathematical Analysis of Non-Recursive Algorithm.Mathematical Analysis of Non-Recursive Algorithm.
Mathematical Analysis of Non-Recursive Algorithm.mohanrathod18
 
Lecture 01 introduction to compiler
Lecture 01 introduction to compilerLecture 01 introduction to compiler
Lecture 01 introduction to compilerIffat Anjum
 
And or graph
And or graphAnd or graph
And or graphAli A Jalil
 
Algorithm Introduction
Algorithm IntroductionAlgorithm Introduction
Algorithm IntroductionAshim Lamichhane
 
Fundamentals of the Analysis of Algorithm Efficiency
Fundamentals of the Analysis of Algorithm EfficiencyFundamentals of the Analysis of Algorithm Efficiency
Fundamentals of the Analysis of Algorithm EfficiencySaranya Natarajan
 
Design and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptxDesign and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptxSyed Zaid Irshad
 
Elements of dynamic programming
Elements of dynamic programmingElements of dynamic programming
Elements of dynamic programmingTafhim Islam
 

What's hot (20)

Algorithmic problem solving
Algorithmic problem solvingAlgorithmic problem solving
Algorithmic problem solving
 
Ai lecture 01(unit03)
Ai lecture  01(unit03)Ai lecture  01(unit03)
Ai lecture 01(unit03)
 
Matrix chain multiplication
Matrix chain multiplicationMatrix chain multiplication
Matrix chain multiplication
 
Fundamental of Algorithms
Fundamental of Algorithms Fundamental of Algorithms
Fundamental of Algorithms
 
Compiler Design
Compiler DesignCompiler Design
Compiler Design
 
Introduction to Compiler design
Introduction to Compiler design Introduction to Compiler design
Introduction to Compiler design
 
Design and analysis of algorithms
Design and analysis of algorithmsDesign and analysis of algorithms
Design and analysis of algorithms
 
Time and space complexity
Time and space complexityTime and space complexity
Time and space complexity
 
Greedy Algorihm
Greedy AlgorihmGreedy Algorihm
Greedy Algorihm
 
Introduction to data structures and Algorithm
Introduction to data structures and AlgorithmIntroduction to data structures and Algorithm
Introduction to data structures and Algorithm
 
Mathematical Analysis of Non-Recursive Algorithm.
Mathematical Analysis of Non-Recursive Algorithm.Mathematical Analysis of Non-Recursive Algorithm.
Mathematical Analysis of Non-Recursive Algorithm.
 
Lecture 01 introduction to compiler
Lecture 01 introduction to compilerLecture 01 introduction to compiler
Lecture 01 introduction to compiler
 
And or graph
And or graphAnd or graph
And or graph
 
Graph coloring problem
Graph coloring problemGraph coloring problem
Graph coloring problem
 
Algorithm Introduction
Algorithm IntroductionAlgorithm Introduction
Algorithm Introduction
 
Daa notes 1
Daa notes 1Daa notes 1
Daa notes 1
 
Fundamentals of the Analysis of Algorithm Efficiency
Fundamentals of the Analysis of Algorithm EfficiencyFundamentals of the Analysis of Algorithm Efficiency
Fundamentals of the Analysis of Algorithm Efficiency
 
Design and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptxDesign and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptx
 
Phases of Compiler
Phases of CompilerPhases of Compiler
Phases of Compiler
 
Elements of dynamic programming
Elements of dynamic programmingElements of dynamic programming
Elements of dynamic programming
 

Similar to Notion of an algorithm

19IS402_LP1_LM_22-23.pdf
19IS402_LP1_LM_22-23.pdf19IS402_LP1_LM_22-23.pdf
19IS402_LP1_LM_22-23.pdfGOWTHAMR721887
 
Optimization Problems Solved by Different Platforms Say Optimum Tool Box (Mat...
Optimization Problems Solved by Different Platforms Say Optimum Tool Box (Mat...Optimization Problems Solved by Different Platforms Say Optimum Tool Box (Mat...
Optimization Problems Solved by Different Platforms Say Optimum Tool Box (Mat...IRJET Journal
 
Design and Analysis Algorithms.pdf
Design and Analysis Algorithms.pdfDesign and Analysis Algorithms.pdf
Design and Analysis Algorithms.pdfHarshNagda5
 
Data Structures and Algorithms Unit 01
Data Structures and Algorithms Unit 01Data Structures and Algorithms Unit 01
Data Structures and Algorithms Unit 01Prashanth Shivakumar
 
Algorithm Specification and Data Abstraction
Algorithm Specification and Data Abstraction Algorithm Specification and Data Abstraction
Algorithm Specification and Data Abstraction Ashutosh Satapathy
 
A review of automatic differentiationand its efficient implementation
A review of automatic differentiationand its efficient implementationA review of automatic differentiationand its efficient implementation
A review of automatic differentiationand its efficient implementationssuserfa7e73
 
UNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.pptUNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.pptracha49
 
UNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.pptUNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.pptSamridhiGulati4
 
Introduction to Design Algorithm And Analysis.ppt
Introduction to Design Algorithm And Analysis.pptIntroduction to Design Algorithm And Analysis.ppt
Introduction to Design Algorithm And Analysis.pptBhargaviDalal4
 
Design and analysis of computer algorithms
Design and analysis of computer algorithmsDesign and analysis of computer algorithms
Design and analysis of computer algorithms Krishna Chaytaniah
 
251 - Alogarithms Lects.pdf
251 - Alogarithms Lects.pdf251 - Alogarithms Lects.pdf
251 - Alogarithms Lects.pdfAbdulkadir Jibril
 
chapter 1
chapter 1chapter 1
chapter 1yatheesha
 
CS8451 DAA Unit-I.pptx
CS8451 DAA Unit-I.pptxCS8451 DAA Unit-I.pptx
CS8451 DAA Unit-I.pptxBolliniNivas
 
Algorithm & data structures lec1
Algorithm & data structures lec1Algorithm & data structures lec1
Algorithm & data structures lec1Abdul Khan
 
Datascience101presentation4
Datascience101presentation4Datascience101presentation4
Datascience101presentation4Salford Systems
 
GRID COMPUTING: STRATEGIC DECISION MAKING IN RESOURCE SELECTION
GRID COMPUTING: STRATEGIC DECISION MAKING IN RESOURCE SELECTIONGRID COMPUTING: STRATEGIC DECISION MAKING IN RESOURCE SELECTION
GRID COMPUTING: STRATEGIC DECISION MAKING IN RESOURCE SELECTIONIJCSEA Journal
 
A tour of the top 10 algorithms for machine learning newbies
A tour of the top 10 algorithms for machine learning newbiesA tour of the top 10 algorithms for machine learning newbies
A tour of the top 10 algorithms for machine learning newbiesVimal Gupta
 
11 Unit 1 Problem Solving Techniques
11  Unit 1 Problem Solving Techniques11  Unit 1 Problem Solving Techniques
11 Unit 1 Problem Solving TechniquesPraveen M Jigajinni
 

Similar to Notion of an algorithm (20)

19IS402_LP1_LM_22-23.pdf
19IS402_LP1_LM_22-23.pdf19IS402_LP1_LM_22-23.pdf
19IS402_LP1_LM_22-23.pdf
 
Optimization Problems Solved by Different Platforms Say Optimum Tool Box (Mat...
Optimization Problems Solved by Different Platforms Say Optimum Tool Box (Mat...Optimization Problems Solved by Different Platforms Say Optimum Tool Box (Mat...
Optimization Problems Solved by Different Platforms Say Optimum Tool Box (Mat...
 
Design and Analysis Algorithms.pdf
Design and Analysis Algorithms.pdfDesign and Analysis Algorithms.pdf
Design and Analysis Algorithms.pdf
 
Data Structures and Algorithms Unit 01
Data Structures and Algorithms Unit 01Data Structures and Algorithms Unit 01
Data Structures and Algorithms Unit 01
 
Algorithm Specification and Data Abstraction
Algorithm Specification and Data Abstraction Algorithm Specification and Data Abstraction
Algorithm Specification and Data Abstraction
 
A review of automatic differentiationand its efficient implementation
A review of automatic differentiationand its efficient implementationA review of automatic differentiationand its efficient implementation
A review of automatic differentiationand its efficient implementation
 
Unit i
Unit iUnit i
Unit i
 
UNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.pptUNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.ppt
 
UNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.pptUNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.ppt
 
Introduction to Design Algorithm And Analysis.ppt
Introduction to Design Algorithm And Analysis.pptIntroduction to Design Algorithm And Analysis.ppt
Introduction to Design Algorithm And Analysis.ppt
 
Design and analysis of computer algorithms
Design and analysis of computer algorithmsDesign and analysis of computer algorithms
Design and analysis of computer algorithms
 
Unit i
Unit iUnit i
Unit i
 
251 - Alogarithms Lects.pdf
251 - Alogarithms Lects.pdf251 - Alogarithms Lects.pdf
251 - Alogarithms Lects.pdf
 
chapter 1
chapter 1chapter 1
chapter 1
 
CS8451 DAA Unit-I.pptx
CS8451 DAA Unit-I.pptxCS8451 DAA Unit-I.pptx
CS8451 DAA Unit-I.pptx
 
Algorithm & data structures lec1
Algorithm & data structures lec1Algorithm & data structures lec1
Algorithm & data structures lec1
 
Datascience101presentation4
Datascience101presentation4Datascience101presentation4
Datascience101presentation4
 
GRID COMPUTING: STRATEGIC DECISION MAKING IN RESOURCE SELECTION
GRID COMPUTING: STRATEGIC DECISION MAKING IN RESOURCE SELECTIONGRID COMPUTING: STRATEGIC DECISION MAKING IN RESOURCE SELECTION
GRID COMPUTING: STRATEGIC DECISION MAKING IN RESOURCE SELECTION
 
A tour of the top 10 algorithms for machine learning newbies
A tour of the top 10 algorithms for machine learning newbiesA tour of the top 10 algorithms for machine learning newbies
A tour of the top 10 algorithms for machine learning newbies
 
11 Unit 1 Problem Solving Techniques
11  Unit 1 Problem Solving Techniques11  Unit 1 Problem Solving Techniques
11 Unit 1 Problem Solving Techniques
 

More from Nisha Soms

Asymptotic analysis
Asymptotic analysisAsymptotic analysis
Asymptotic analysisNisha Soms
 
Algorithm analysis
Algorithm analysisAlgorithm analysis
Algorithm analysisNisha Soms
 
Divide and conquer strategy
Divide and conquer strategyDivide and conquer strategy
Divide and conquer strategyNisha Soms
 
Merge sort
Merge sortMerge sort
Merge sortNisha Soms
 
Depth First Search and Breadth First Search
Depth First Search and Breadth First SearchDepth First Search and Breadth First Search
Depth First Search and Breadth First SearchNisha Soms
 
Linear and Binary search
Linear and Binary searchLinear and Binary search
Linear and Binary searchNisha Soms
 

More from Nisha Soms (6)

Asymptotic analysis
Asymptotic analysisAsymptotic analysis
Asymptotic analysis
 
Algorithm analysis
Algorithm analysisAlgorithm analysis
Algorithm analysis
 
Divide and conquer strategy
Divide and conquer strategyDivide and conquer strategy
Divide and conquer strategy
 
Merge sort
Merge sortMerge sort
Merge sort
 
Depth First Search and Breadth First Search
Depth First Search and Breadth First SearchDepth First Search and Breadth First Search
Depth First Search and Breadth First Search
 
Linear and Binary search
Linear and Binary searchLinear and Binary search
Linear and Binary search
 

Recently uploaded

ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 

Recently uploaded (20)

TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 

Notion of an algorithm

  • 1. UCSE010 - DESIGN AND ANALYSIS OF ALGORITHMS 1 Dr.Nisha Soms/SRIT Semester-06/2020-2021
  • 2. Why study Algorithm?  It is important for all other branches of computer science  Plays a key role in modern technological innovation  As a developer, our everyday work is to solve problems and algorithms solve problems very efficiently.  Practicing algorithms will increase your skill and your visibility at work thereby building a strong foundation in logical thinking and problem solving 2 When we use Algorithmic Thinking, we direct our behaviours to specific situations and in the direction of future events. Dr.Nisha Soms/SRIT
  • 3. How do algorithms shape our world?  Google's PageRank algorithm determines how pages on the internet are displayed and ranked based on their relevance to your search.  Sites such as Amazon and Netflix base recommendations on Collaborative Filtering algorithms that look at other uses with similar interests and tastes and subsequently deliver predictions for purchases and shows.  Mapping applications such as Google Maps need to calculate routes through cities, taking into account distance, traffic, and accidents. Dijkstra's algorithm, helps us to find these optimal paths. 3 Dr.Nisha Soms/SRIT
  • 4. What is an Algorithm?  A finite set of instructions that specifies a sequence of operation  These instructions are carried out to solve a specific problem or class of problems 4 All algorithms are essentially detailed sets of instructions that computers follow to arrive at an answer. Humans also constantly utilize (simpler) algorithms: for example, a recipe to make dinner is an algorithm. Dr.Nisha Soms/SRIT
  • 5. 5  Formal Definition: An algorithm is a sequence of unambiguous instructions for solving a problem, i.e., for obtaining a required output for any legitimate input in a finite amount of time. Semester-06/2020-2021 Dr.Nisha Soms/SRIT Ref: Introduction to the Design and Analysis of Algorithms (3rd ed.), Anany Levitin
  • 6. 6 An algorithm Takes the input and transforms it into an adequate output. The range of inputs for which an algorithm works has to be specified carefully. Must be independent from any programming languages The non-ambiguity requirement for each step of an algorithm cannot be compromised. The same algorithm can be represented in several different ways. There may exist several algorithms for solving the same problem. Algorithms for the same problem can be based on very different ideas and can solve the problem with dramatically different speeds. Semester-06/2020-2021 Dr.Nisha Soms/SRIT
  • 7. 7 METHOD I - Euclid’s algorithm METHOD II - Consecutive integer checking algorithm METHOD III - Middle- school procedure Step 1 If n = 0, return the value of m as the answer and stop; otherwise, proceed to Step 2. Step 2 Divide m by n and assign the value of the remainder to r. Step 3 Assign the value of n to m and the value of r to n. Go to Step 1. Step 1 Assign the value of min{m, n} to t. Step 2 Divide m by t. If the remainder of this division is 0, go to Step 3; otherwise, go to Step 4. Step 3 Divide n by t. If the remainder of this division is 0, return the value of t as the answer and stop; otherwise, proceed to Step 4. Step 4 Decrease the value of t by 1. Go to Step 2. Step 1 Find the prime factors of m. Step 2 Find the prime factors of n. Step 3 Identify all the common factors in the two prime expansions found in Step 4 Compute the product of all the common factors and return it as the greatest common divisor of the numbers given. gcd(60, 24) = gcd(24, 12) = gcd(12, 0) = 12 For numbers 60 and 24, the algorithm will try first 24, then 23, and so on, until it reaches 12, where it stops. 60 = 2 . 2 . 3 . 5 24 = 2 . 2 . 2 . 3 gcd(60, 24) = 2 . 2 . 3 = 12. Semester-06/2020-2021 Dr.Nisha Soms/SRIT
  • 8. 8 To allow a successful execution of programs, algorithms should possess certain qualities. They are: 1. Correctness: if the input conditions are satisfied and the algorithm instructions are executed, then correct output is produced. 2. Termination: the algorithm must terminate after a finite number of steps. This can be ensured if there are no infinite loops. 3. Performance: Quantification of space and time complexities. Semester-06/2020-2021 Dr.Nisha Soms/SRIT
  • 9. Semester-06/2020-2021 Dr.Nisha Soms/SRIT 9 Ref: Introduction to the Design and Analysis of Algorithms (3rd ed.), Anany Levitin
  • 10. 1 0 1. From a practical perspective, the first thing you need to do before designing an algorithm is to understand completely the problem given. â–ŞRead the problem’s description carefully and ask questions if you have any doubts about the problem 2. An input to an algorithm specifies an instance of the problem, the algorithm solves. It is very important to specify exactly the set of instances the algorithm needs to handle. â–ŞIf you fail to do this, your algorithm may work correctly for a majority of inputs but crash on some “boundary” value. Remember that a correct algorithm is not one that works most of the time, but one that works correctly for all legitimate inputs. 3. Do not skimp on this first step of the algorithmic problem- solving process; otherwise, you will run the risk of unnecessary rework. Semester-06/2020-2021 Dr.Nisha Soms/SRIT
  • 11. 1 1  Once you completely understand a problem, you need to ascertain the capabilities of the computational device the algorithm is intended for.  The vast majority of algorithms in use today are still destined to be programmed for a computer closely resembling the von Neumann machine Semester-06/2020-2021 Dr.Nisha Soms/SRIT
  • 12. 1 2  The next principal decision is to choose between solving the problem exactly (known as exact algorithm ) or solving it approximately (known as approximation algorithm)  Why would one opt for an approximation algorithm?  First, there are important problems that simply cannot be solved exactly for most of their instances; examples include extracting square roots, solving nonlinear equations, and evaluating definite integrals.  Second, available algorithms for solving a problem exactly can be unacceptably slow because of the problem’s intrinsic complexity.  Third, an approximation algorithm can be a part of a more sophisticated algorithm that solves a problem exactly. Semester-06/2020-2021 Dr.Nisha Soms/SRIT
  • 13. 1 3  An algorithm design technique (or “strategy” or “paradigm”) is a general approach to solving problems algorithmically that is applicable to a variety of problems from different areas of computing.  Learning these techniques is of utmost importance for the following reasons:  First, they provide guidance for designing algorithms for new problems, i.e., problems for which there is no known satisfactory algorithm.  Second, Algorithm design techniques make it possible to classify algorithms according to an underlying design idea; therefore, they can serve as a natural way to both categorize and study algorithms Semester-06/2020-2021 Dr.Nisha Soms/SRIT
  • 14. 1 4  Pseudocode is a mixture of a natural language and programming language like constructs.  Pseudocode is usually more precise than natural language, and its usage often yields more concise algorithm descriptions.  In the earlier days of computing, the dominant vehicle for specifying algorithms was a flowchart, a method of expressing an algorithm by a collection of connected geometric shapes containing descriptions of the algorithm’s steps.  This representation technique has proved to be inconvenient for all but very simple algorithms; nowadays, it can be found only in old algorithm books. Semester-06/2020-2021 Dr.Nisha Soms/SRIT
  • 15. 1 5  A common technique for proving correctness is to use mathematical induction because an algorithm’s iterations provide a natural sequence of steps needed for such proofs.  To show that an algorithm is incorrect, you need just one instance of its input for which the algorithm fails. Semester-06/2020-2021 Dr.Nisha Soms/SRIT
  • 16. 1 6 There are two kinds of algorithm efficiency: â–Ş time efficiency, indicating how fast the algorithm runs, and â–Ş space efficiency, indicating how much extra memory it uses.  Another desirable characteristic of an algorithm is simplicity. â–Ş Because simpler algorithms are easier to understand and easier to program; Another desirable characteristic of an algorithm is generality. Semester-06/2020-2021 Dr.Nisha Soms/SRIT
  • 17. 1 7 Most algorithms are destined to be ultimately implemented as computer programs. A working program provides an additional opportunity in allowing an empirical analysis of the underlying algorithm. Such an analysis is based on timing the program on several inputs and then analyzing the results obtained Semester-06/2020-2021 Dr.Nisha Soms/SRIT
  • 18.  Sorting  Searching  String processing  Graph problems  Combinatorial problems  Geometric problems  Numerical problems Semester-06/2020-2021 Dr.Nisha Soms/SRIT 18
  • 19.  https://www.cse.iitd.ac.in/~mausam/courses/c ol106/autumn2017/lectures/02-asymptotic.pdf  https://www.coursehero.com/file/51912947/L0 1-Introppt/  https://anh.cs.luc.edu › notes  Introduction to the Design and Analysis of Algorithms (3rd ed.), Anany Levitin Semester-06/2020-2021 Dr.Nisha Soms/SRIT 19
  • 20. Please Click Like, Share and Subscribe ! Semester-06/2020-2021 Dr.Nisha Soms/SRIT 20