SlideShare a Scribd company logo
1 of 19
Introduction to Algorithms
By
Hanumat Sastry. G
Two Phases of Programming
• 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
Understand the problem
Decide on computational means
Exact vs approximate solution
Data structures
Algorithm design technique

Design an algorithm
Prove correctness
Analyze the algorithm
Code the algorithm
3
Algorithms
• A sequence of unambiguous
instructions for solving a
problem, i.e. for obtaining the
required output for any legitimate
input in

a finite amount of time
Algorithm Characteristics
• Input : Zero or more quantities or externally
supplied.
• Output: At least one quantity is produced.
• Definiteness: Each instruction is clear and
unambiguous.
• Finiteness: The algorithm should terminate
after a finite number of steps.
• Effectiveness:
How to Represent an Algorithm
Algorithm can be represented in 3 ways.
1. In Natural Language (English etc…)
2. Pseudo Code.
3. Real Programming Language.
Popular representation is Pseudo Code.
Pseudo Code Convention for Algorithm
• Pseudo code consists of keywords and Englishlike phrases which specify the flow control.
• Pseudo code representation highlights the
Computational aspects by abstracting the
implementation details.
Sum of ‘n’ numbers
Algorithm in Natural
Language
Step 1: Select n number.
Step 2: Set sum S to Zero.
Step 3: Repeat from first
number to nth number
i.e S=S+A[i].
Step 4: Return sum (S).

Algorithm in Pseudo Code.
1.
2.
3.
4.

S<-0
for i<-1 to n
S<-S+A[i]
return S.
gcd(m,n)
Algorithm-1

while n ≠0 do
r ← m mod n
m←n
n ←r
return m

Algorithm-2
1. t ← min (m ,n)
2. if m % t = 0 goto 3,
else goto 4
3. if n % t = 0 return t,
else goto 4

4. t ← t - 1
5. goto 2
General approaches to
algorithm design
Divide and conquer

Greedy method
Dynamic Programming
Basic Search and Traversal Technique

Graph Theory
Linear Programming
Approximation Algorithm
NP Problem
Some Applications
• Study problems these techniques can be
applied to
– sorting
– data retrieval

– network routing
– Games
– etc
Computation Models
• Turing Machine Model
• Random Access Machine (RAM) Model.
Analysis of Algorithms
• The present day algorithms are based on the
RAM (Random Access Machine) model.
• In RAM model, instructions execute one after
another with no, concurrent operations.
Analysis of Algorithms
• Worst Case Complexity
• Average Case Complexity
• Best Case Complexity
Worst Case Complexity
• The Worst Case Complexity of an algorithm is
the function defined by the maximum number
of steps taken on any instance size n.
Best Case Complexity
• The best case complexity of the algorithm is
the function defined by the minimum number
of steps taken on any instance of size n.
Average Case Complexity
• The average case complexity of the algorithm
is the function defined by an average number
of steps taken on an instance of size n.
Graphical representation of Worst
Case, Average Case and Best Case
Complexity
Exercises
• Write an algorithm for product of two matrix
• Design an algorithm for finding square of
given number
• Design an algorithm to find factorial of a
number

More Related Content

What's hot

Lecture 6-cs648 Randomized Algorithms
Lecture 6-cs648 Randomized AlgorithmsLecture 6-cs648 Randomized Algorithms
Lecture 6-cs648 Randomized AlgorithmsAnshul Yadav
 
Lecture 2 role of algorithms in computing
Lecture 2   role of algorithms in computingLecture 2   role of algorithms in computing
Lecture 2 role of algorithms in computingjayavignesh86
 
Algorithm defination, design & Implementation
Algorithm defination, design & ImplementationAlgorithm defination, design & Implementation
Algorithm defination, design & ImplementationBilal Maqbool ツ
 
03 algorithm properties
03 algorithm properties03 algorithm properties
03 algorithm propertiesLincoln School
 
Aad introduction
Aad introductionAad introduction
Aad introductionMr SMAK
 
Algorithm Design Presentation
Algorithm Design PresentationAlgorithm Design Presentation
Algorithm Design PresentationKawsar Ahmed
 
Algorithmic problem solving
Algorithmic problem solvingAlgorithmic problem solving
Algorithmic problem solvingPrabhakaran V M
 
Lecture 1 objective and course plan
Lecture 1   objective and course planLecture 1   objective and course plan
Lecture 1 objective and course planjayavignesh86
 
Dynamic programming 2
Dynamic programming 2Dynamic programming 2
Dynamic programming 2Roy Thomas
 
Data Abstraction (Chapter 1)
Data Abstraction (Chapter 1)Data Abstraction (Chapter 1)
Data Abstraction (Chapter 1)LeulTewolde
 
Data Structures - Lecture 1 [introduction]
Data Structures - Lecture 1 [introduction]Data Structures - Lecture 1 [introduction]
Data Structures - Lecture 1 [introduction]Muhammad Hammad Waseem
 
Pengenalan Algoritma
Pengenalan AlgoritmaPengenalan Algoritma
Pengenalan AlgoritmaAjeng Savitri
 
Dynamic Programming
Dynamic ProgrammingDynamic Programming
Dynamic Programmingparamalways
 
Unit 1-problem solving with algorithm
Unit 1-problem solving with algorithmUnit 1-problem solving with algorithm
Unit 1-problem solving with algorithmrajkumar1631010038
 
Algorithm and Programming (Introduction of Algorithms)
Algorithm and Programming (Introduction of Algorithms)Algorithm and Programming (Introduction of Algorithms)
Algorithm and Programming (Introduction of Algorithms)Adam Mukharil Bachtiar
 
Ic lecture6 architecture and algo
Ic lecture6 architecture and algoIc lecture6 architecture and algo
Ic lecture6 architecture and algoAttaullahRahimoon
 

What's hot (19)

Lecture 6-cs648 Randomized Algorithms
Lecture 6-cs648 Randomized AlgorithmsLecture 6-cs648 Randomized Algorithms
Lecture 6-cs648 Randomized Algorithms
 
Lecture 2 role of algorithms in computing
Lecture 2   role of algorithms in computingLecture 2   role of algorithms in computing
Lecture 2 role of algorithms in computing
 
Algorithm defination, design & Implementation
Algorithm defination, design & ImplementationAlgorithm defination, design & Implementation
Algorithm defination, design & Implementation
 
phases of algorithm
phases of algorithmphases of algorithm
phases of algorithm
 
03 algorithm properties
03 algorithm properties03 algorithm properties
03 algorithm properties
 
Aad introduction
Aad introductionAad introduction
Aad introduction
 
Algorithm Design Presentation
Algorithm Design PresentationAlgorithm Design Presentation
Algorithm Design Presentation
 
Algorithmic problem solving
Algorithmic problem solvingAlgorithmic problem solving
Algorithmic problem solving
 
Lecture 1 objective and course plan
Lecture 1   objective and course planLecture 1   objective and course plan
Lecture 1 objective and course plan
 
Dynamic programming 2
Dynamic programming 2Dynamic programming 2
Dynamic programming 2
 
Daa unit 1
Daa unit 1Daa unit 1
Daa unit 1
 
Data Abstraction (Chapter 1)
Data Abstraction (Chapter 1)Data Abstraction (Chapter 1)
Data Abstraction (Chapter 1)
 
Data Structures - Lecture 1 [introduction]
Data Structures - Lecture 1 [introduction]Data Structures - Lecture 1 [introduction]
Data Structures - Lecture 1 [introduction]
 
Pengenalan Algoritma
Pengenalan AlgoritmaPengenalan Algoritma
Pengenalan Algoritma
 
Dynamic Programming
Dynamic ProgrammingDynamic Programming
Dynamic Programming
 
#1 designandanalysis of algo
#1 designandanalysis of algo#1 designandanalysis of algo
#1 designandanalysis of algo
 
Unit 1-problem solving with algorithm
Unit 1-problem solving with algorithmUnit 1-problem solving with algorithm
Unit 1-problem solving with algorithm
 
Algorithm and Programming (Introduction of Algorithms)
Algorithm and Programming (Introduction of Algorithms)Algorithm and Programming (Introduction of Algorithms)
Algorithm and Programming (Introduction of Algorithms)
 
Ic lecture6 architecture and algo
Ic lecture6 architecture and algoIc lecture6 architecture and algo
Ic lecture6 architecture and algo
 

Viewers also liked

Introduction to programming01
Introduction to programming01Introduction to programming01
Introduction to programming01Nadim Ahmed
 
The Burrows-Wheeler Algorithm
The Burrows-Wheeler AlgorithmThe Burrows-Wheeler Algorithm
The Burrows-Wheeler AlgorithmMustafa Salam
 
Intro To Programming Concepts
Intro To Programming ConceptsIntro To Programming Concepts
Intro To Programming ConceptsJussi Pohjolainen
 
Lect 1. introduction to programming languages
Lect 1. introduction to programming languagesLect 1. introduction to programming languages
Lect 1. introduction to programming languagesVarun Garg
 
Programming Fundamentals
Programming FundamentalsProgramming Fundamentals
Programming FundamentalsHassan293
 
Chapter 1 - An Introduction to Programming
Chapter 1 - An Introduction to ProgrammingChapter 1 - An Introduction to Programming
Chapter 1 - An Introduction to Programmingmshellman
 
Introduction to Algorithms & flow charts
Introduction to Algorithms & flow chartsIntroduction to Algorithms & flow charts
Introduction to Algorithms & flow chartsYash Gupta
 
Ch 8 introduction to data structures
Ch 8 introduction to data structuresCh 8 introduction to data structures
Ch 8 introduction to data structuresChaffey College
 
Introduction to basic programming
Introduction to basic programmingIntroduction to basic programming
Introduction to basic programmingJordan Delacruz
 
Learn Data Structures With Myassignmenthelp.Net
Learn Data Structures With Myassignmenthelp.NetLearn Data Structures With Myassignmenthelp.Net
Learn Data Structures With Myassignmenthelp.NetSteve Johnson
 
Computer Programming: Chapter 1
Computer Programming: Chapter 1Computer Programming: Chapter 1
Computer Programming: Chapter 1Atit Patumvan
 
Introduction to computer programming
Introduction to computer programmingIntroduction to computer programming
Introduction to computer programmingNoel Malle
 
Introduction to data structures and Algorithm
Introduction to data structures and AlgorithmIntroduction to data structures and Algorithm
Introduction to data structures and AlgorithmDhaval Kaneria
 

Viewers also liked (20)

Introduction to programming01
Introduction to programming01Introduction to programming01
Introduction to programming01
 
The Burrows-Wheeler Algorithm
The Burrows-Wheeler AlgorithmThe Burrows-Wheeler Algorithm
The Burrows-Wheeler Algorithm
 
Intro To Programming Concepts
Intro To Programming ConceptsIntro To Programming Concepts
Intro To Programming Concepts
 
Lect 1. introduction to programming languages
Lect 1. introduction to programming languagesLect 1. introduction to programming languages
Lect 1. introduction to programming languages
 
Programming Fundamentals
Programming FundamentalsProgramming Fundamentals
Programming Fundamentals
 
Chapter 1 - An Introduction to Programming
Chapter 1 - An Introduction to ProgrammingChapter 1 - An Introduction to Programming
Chapter 1 - An Introduction to Programming
 
test1
test1test1
test1
 
Introduction to Algorithms & flow charts
Introduction to Algorithms & flow chartsIntroduction to Algorithms & flow charts
Introduction to Algorithms & flow charts
 
Ch 8 introduction to data structures
Ch 8 introduction to data structuresCh 8 introduction to data structures
Ch 8 introduction to data structures
 
Introduction to basic programming
Introduction to basic programmingIntroduction to basic programming
Introduction to basic programming
 
Learn Data Structures With Myassignmenthelp.Net
Learn Data Structures With Myassignmenthelp.NetLearn Data Structures With Myassignmenthelp.Net
Learn Data Structures With Myassignmenthelp.Net
 
Computer Programming: Chapter 1
Computer Programming: Chapter 1Computer Programming: Chapter 1
Computer Programming: Chapter 1
 
Introduction to-programming
Introduction to-programmingIntroduction to-programming
Introduction to-programming
 
Algorithms - Introduction to computer programming
Algorithms - Introduction to computer programmingAlgorithms - Introduction to computer programming
Algorithms - Introduction to computer programming
 
SSL12 Entropy
SSL12 EntropySSL12 Entropy
SSL12 Entropy
 
Arithmetic Coding
Arithmetic CodingArithmetic Coding
Arithmetic Coding
 
Chap 1 c++
Chap 1 c++Chap 1 c++
Chap 1 c++
 
Introduction to computer programming
Introduction to computer programmingIntroduction to computer programming
Introduction to computer programming
 
Entropy
EntropyEntropy
Entropy
 
Introduction to data structures and Algorithm
Introduction to data structures and AlgorithmIntroduction to data structures and Algorithm
Introduction to data structures and Algorithm
 

Similar to Introduction to Algorithms Design Techniques and Analysis

DAA 1 ppt.pptx
DAA 1 ppt.pptxDAA 1 ppt.pptx
DAA 1 ppt.pptxRAJESH S
 
DAA ppt.pptx
DAA ppt.pptxDAA ppt.pptx
DAA ppt.pptxRAJESH S
 
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
 
Algorithms & Complexity Calculation
Algorithms & Complexity CalculationAlgorithms & Complexity Calculation
Algorithms & Complexity CalculationAkhil Kaushik
 
Analysis and Design of Algorithms
Analysis and Design of AlgorithmsAnalysis and Design of Algorithms
Analysis and Design of AlgorithmsBulbul Agrawal
 
Unit 1, ADA.pptx
Unit 1, ADA.pptxUnit 1, ADA.pptx
Unit 1, ADA.pptxjinkhatima
 
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...AntareepMajumder
 
Part 1.ppt
Part 1.pptPart 1.ppt
Part 1.pptRAJESH S
 
Introduction to Algorithms Complexity Analysis
Introduction to Algorithms Complexity Analysis Introduction to Algorithms Complexity Analysis
Introduction to Algorithms Complexity Analysis Dr. Pankaj Agarwal
 
Analysis of Algorithm full version 2024.pptx
Analysis of Algorithm  full version  2024.pptxAnalysis of Algorithm  full version  2024.pptx
Analysis of Algorithm full version 2024.pptxrajesshs31r
 
Design Analysis of Alogorithm 1 ppt 2024.pptx
Design Analysis of Alogorithm 1 ppt 2024.pptxDesign Analysis of Alogorithm 1 ppt 2024.pptx
Design Analysis of Alogorithm 1 ppt 2024.pptxrajesshs31r
 
Chapter1.1 Introduction.ppt
Chapter1.1 Introduction.pptChapter1.1 Introduction.ppt
Chapter1.1 Introduction.pptTekle12
 
Chapter1.1 Introduction to design and analysis of algorithm.ppt
Chapter1.1 Introduction to design and analysis of algorithm.pptChapter1.1 Introduction to design and analysis of algorithm.ppt
Chapter1.1 Introduction to design and analysis of algorithm.pptTekle12
 
2. Introduction to Algorithm.pptx
2. Introduction to Algorithm.pptx2. Introduction to Algorithm.pptx
2. Introduction to Algorithm.pptxRahikAhmed1
 
Algorithm - Introduction
Algorithm - IntroductionAlgorithm - Introduction
Algorithm - IntroductionMadhu Bala
 
Algorithm Analysis.pdf
Algorithm Analysis.pdfAlgorithm Analysis.pdf
Algorithm Analysis.pdfNayanChandak1
 
Design & Analysis of Algorithm course .pptx
Design & Analysis of Algorithm course .pptxDesign & Analysis of Algorithm course .pptx
Design & Analysis of Algorithm course .pptxJeevaMCSEKIOT
 
01 Introduction to analysis of Algorithms.pptx
01 Introduction to analysis of Algorithms.pptx01 Introduction to analysis of Algorithms.pptx
01 Introduction to analysis of Algorithms.pptxssuser586772
 
CH-1.1 Introduction (1).pptx
CH-1.1 Introduction (1).pptxCH-1.1 Introduction (1).pptx
CH-1.1 Introduction (1).pptxsatvikkushwaha1
 

Similar to Introduction to Algorithms Design Techniques and Analysis (20)

DAA 1 ppt.pptx
DAA 1 ppt.pptxDAA 1 ppt.pptx
DAA 1 ppt.pptx
 
DAA ppt.pptx
DAA ppt.pptxDAA ppt.pptx
DAA ppt.pptx
 
Design and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptxDesign and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptx
 
Algorithms & Complexity Calculation
Algorithms & Complexity CalculationAlgorithms & Complexity Calculation
Algorithms & Complexity Calculation
 
Analysis and Design of Algorithms
Analysis and Design of AlgorithmsAnalysis and Design of Algorithms
Analysis and Design of Algorithms
 
Unit 1, ADA.pptx
Unit 1, ADA.pptxUnit 1, ADA.pptx
Unit 1, ADA.pptx
 
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...
 
Part 1.ppt
Part 1.pptPart 1.ppt
Part 1.ppt
 
Introduction to Algorithms Complexity Analysis
Introduction to Algorithms Complexity Analysis Introduction to Algorithms Complexity Analysis
Introduction to Algorithms Complexity Analysis
 
Analysis of Algorithm full version 2024.pptx
Analysis of Algorithm  full version  2024.pptxAnalysis of Algorithm  full version  2024.pptx
Analysis of Algorithm full version 2024.pptx
 
Design Analysis of Alogorithm 1 ppt 2024.pptx
Design Analysis of Alogorithm 1 ppt 2024.pptxDesign Analysis of Alogorithm 1 ppt 2024.pptx
Design Analysis of Alogorithm 1 ppt 2024.pptx
 
Chapter1.1 Introduction.ppt
Chapter1.1 Introduction.pptChapter1.1 Introduction.ppt
Chapter1.1 Introduction.ppt
 
Chapter1.1 Introduction to design and analysis of algorithm.ppt
Chapter1.1 Introduction to design and analysis of algorithm.pptChapter1.1 Introduction to design and analysis of algorithm.ppt
Chapter1.1 Introduction to design and analysis of algorithm.ppt
 
2. Introduction to Algorithm.pptx
2. Introduction to Algorithm.pptx2. Introduction to Algorithm.pptx
2. Introduction to Algorithm.pptx
 
Algorithm - Introduction
Algorithm - IntroductionAlgorithm - Introduction
Algorithm - Introduction
 
Algorithm Analysis.pdf
Algorithm Analysis.pdfAlgorithm Analysis.pdf
Algorithm Analysis.pdf
 
Lec1.ppt
Lec1.pptLec1.ppt
Lec1.ppt
 
Design & Analysis of Algorithm course .pptx
Design & Analysis of Algorithm course .pptxDesign & Analysis of Algorithm course .pptx
Design & Analysis of Algorithm course .pptx
 
01 Introduction to analysis of Algorithms.pptx
01 Introduction to analysis of Algorithms.pptx01 Introduction to analysis of Algorithms.pptx
01 Introduction to analysis of Algorithms.pptx
 
CH-1.1 Introduction (1).pptx
CH-1.1 Introduction (1).pptxCH-1.1 Introduction (1).pptx
CH-1.1 Introduction (1).pptx
 

More from Kumar

Graphics devices
Graphics devicesGraphics devices
Graphics devicesKumar
 
Fill area algorithms
Fill area algorithmsFill area algorithms
Fill area algorithmsKumar
 
region-filling
region-fillingregion-filling
region-fillingKumar
 
Bresenham derivation
Bresenham derivationBresenham derivation
Bresenham derivationKumar
 
Bresenham circles and polygons derication
Bresenham circles and polygons dericationBresenham circles and polygons derication
Bresenham circles and polygons dericationKumar
 
Introductionto xslt
Introductionto xsltIntroductionto xslt
Introductionto xsltKumar
 
Extracting data from xml
Extracting data from xmlExtracting data from xml
Extracting data from xmlKumar
 
Xml basics
Xml basicsXml basics
Xml basicsKumar
 
XML Schema
XML SchemaXML Schema
XML SchemaKumar
 
Publishing xml
Publishing xmlPublishing xml
Publishing xmlKumar
 
Applying xml
Applying xmlApplying xml
Applying xmlKumar
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XMLKumar
 
How to deploy a j2ee application
How to deploy a j2ee applicationHow to deploy a j2ee application
How to deploy a j2ee applicationKumar
 
JNDI, JMS, JPA, XML
JNDI, JMS, JPA, XMLJNDI, JMS, JPA, XML
JNDI, JMS, JPA, XMLKumar
 
EJB Fundmentals
EJB FundmentalsEJB Fundmentals
EJB FundmentalsKumar
 
JSP and struts programming
JSP and struts programmingJSP and struts programming
JSP and struts programmingKumar
 
java servlet and servlet programming
java servlet and servlet programmingjava servlet and servlet programming
java servlet and servlet programmingKumar
 
Introduction to JDBC and JDBC Drivers
Introduction to JDBC and JDBC DriversIntroduction to JDBC and JDBC Drivers
Introduction to JDBC and JDBC DriversKumar
 
Introduction to J2EE
Introduction to J2EEIntroduction to J2EE
Introduction to J2EEKumar
 

More from Kumar (20)

Graphics devices
Graphics devicesGraphics devices
Graphics devices
 
Fill area algorithms
Fill area algorithmsFill area algorithms
Fill area algorithms
 
region-filling
region-fillingregion-filling
region-filling
 
Bresenham derivation
Bresenham derivationBresenham derivation
Bresenham derivation
 
Bresenham circles and polygons derication
Bresenham circles and polygons dericationBresenham circles and polygons derication
Bresenham circles and polygons derication
 
Introductionto xslt
Introductionto xsltIntroductionto xslt
Introductionto xslt
 
Extracting data from xml
Extracting data from xmlExtracting data from xml
Extracting data from xml
 
Xml basics
Xml basicsXml basics
Xml basics
 
XML Schema
XML SchemaXML Schema
XML Schema
 
Publishing xml
Publishing xmlPublishing xml
Publishing xml
 
DTD
DTDDTD
DTD
 
Applying xml
Applying xmlApplying xml
Applying xml
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
 
How to deploy a j2ee application
How to deploy a j2ee applicationHow to deploy a j2ee application
How to deploy a j2ee application
 
JNDI, JMS, JPA, XML
JNDI, JMS, JPA, XMLJNDI, JMS, JPA, XML
JNDI, JMS, JPA, XML
 
EJB Fundmentals
EJB FundmentalsEJB Fundmentals
EJB Fundmentals
 
JSP and struts programming
JSP and struts programmingJSP and struts programming
JSP and struts programming
 
java servlet and servlet programming
java servlet and servlet programmingjava servlet and servlet programming
java servlet and servlet programming
 
Introduction to JDBC and JDBC Drivers
Introduction to JDBC and JDBC DriversIntroduction to JDBC and JDBC Drivers
Introduction to JDBC and JDBC Drivers
 
Introduction to J2EE
Introduction to J2EEIntroduction to J2EE
Introduction to J2EE
 

Recently uploaded

Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
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
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
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
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
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
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersChitralekhaTherkar
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
_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
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 

Recently uploaded (20)

Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
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
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
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
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
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
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
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
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
_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
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 

Introduction to Algorithms Design Techniques and Analysis

  • 2. Two Phases of Programming • 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
  • 3. Understand the problem Decide on computational means Exact vs approximate solution Data structures Algorithm design technique Design an algorithm Prove correctness Analyze the algorithm Code the algorithm 3
  • 4. Algorithms • A sequence of unambiguous instructions for solving a problem, i.e. for obtaining the required output for any legitimate input in a finite amount of time
  • 5. Algorithm Characteristics • Input : Zero or more quantities or externally supplied. • Output: At least one quantity is produced. • Definiteness: Each instruction is clear and unambiguous. • Finiteness: The algorithm should terminate after a finite number of steps. • Effectiveness:
  • 6. How to Represent an Algorithm Algorithm can be represented in 3 ways. 1. In Natural Language (English etc…) 2. Pseudo Code. 3. Real Programming Language. Popular representation is Pseudo Code.
  • 7. Pseudo Code Convention for Algorithm • Pseudo code consists of keywords and Englishlike phrases which specify the flow control. • Pseudo code representation highlights the Computational aspects by abstracting the implementation details.
  • 8. Sum of ‘n’ numbers Algorithm in Natural Language Step 1: Select n number. Step 2: Set sum S to Zero. Step 3: Repeat from first number to nth number i.e S=S+A[i]. Step 4: Return sum (S). Algorithm in Pseudo Code. 1. 2. 3. 4. S<-0 for i<-1 to n S<-S+A[i] return S.
  • 9. gcd(m,n) Algorithm-1 while n ≠0 do r ← m mod n m←n n ←r return m Algorithm-2 1. t ← min (m ,n) 2. if m % t = 0 goto 3, else goto 4 3. if n % t = 0 return t, else goto 4 4. t ← t - 1 5. goto 2
  • 10. General approaches to algorithm design Divide and conquer Greedy method Dynamic Programming Basic Search and Traversal Technique Graph Theory Linear Programming Approximation Algorithm NP Problem
  • 11. Some Applications • Study problems these techniques can be applied to – sorting – data retrieval – network routing – Games – etc
  • 12. Computation Models • Turing Machine Model • Random Access Machine (RAM) Model.
  • 13. Analysis of Algorithms • The present day algorithms are based on the RAM (Random Access Machine) model. • In RAM model, instructions execute one after another with no, concurrent operations.
  • 14. Analysis of Algorithms • Worst Case Complexity • Average Case Complexity • Best Case Complexity
  • 15. Worst Case Complexity • The Worst Case Complexity of an algorithm is the function defined by the maximum number of steps taken on any instance size n.
  • 16. Best Case Complexity • The best case complexity of the algorithm is the function defined by the minimum number of steps taken on any instance of size n.
  • 17. Average Case Complexity • The average case complexity of the algorithm is the function defined by an average number of steps taken on an instance of size n.
  • 18. Graphical representation of Worst Case, Average Case and Best Case Complexity
  • 19. Exercises • Write an algorithm for product of two matrix • Design an algorithm for finding square of given number • Design an algorithm to find factorial of a number