SlideShare a Scribd company logo
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
Ad

More Related Content

What's hot (19)

Lecture 6-cs648 Randomized Algorithms
Lecture 6-cs648 Randomized AlgorithmsLecture 6-cs648 Randomized Algorithms
Lecture 6-cs648 Randomized Algorithms
Anshul 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 computing
jayavignesh86
 
Algorithm defination, design & Implementation
Algorithm defination, design & ImplementationAlgorithm defination, design & Implementation
Algorithm defination, design & Implementation
Bilal Maqbool ツ
 
phases of algorithm
phases of algorithmphases of algorithm
phases of algorithm
sti meycauayan
 
03 algorithm properties
03 algorithm properties03 algorithm properties
03 algorithm properties
Lincoln School
 
Aad introduction
Aad introductionAad introduction
Aad introduction
Mr SMAK
 
Algorithm Design Presentation
Algorithm Design PresentationAlgorithm Design Presentation
Algorithm Design Presentation
Kawsar Ahmed
 
Algorithmic problem solving
Algorithmic problem solvingAlgorithmic problem solving
Algorithmic problem solving
Prabhakaran V M
 
Lecture 1 objective and course plan
Lecture 1   objective and course planLecture 1   objective and course plan
Lecture 1 objective and course plan
jayavignesh86
 
Dynamic programming 2
Dynamic programming 2Dynamic programming 2
Dynamic programming 2
Roy Thomas
 
Daa unit 1
Daa unit 1Daa unit 1
Daa unit 1
Abhimanyu Mishra
 
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 Algoritma
Ajeng Savitri
 
Dynamic Programming
Dynamic ProgrammingDynamic Programming
Dynamic Programming
paramalways
 
#1 designandanalysis of algo
#1 designandanalysis of algo#1 designandanalysis of algo
#1 designandanalysis of algo
Brijida Charizma Ardoña-Navarro
 
Unit 1-problem solving with algorithm
Unit 1-problem solving with algorithmUnit 1-problem solving with algorithm
Unit 1-problem solving with algorithm
rajkumar1631010038
 
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 algo
AttaullahRahimoon
 
Lecture 6-cs648 Randomized Algorithms
Lecture 6-cs648 Randomized AlgorithmsLecture 6-cs648 Randomized Algorithms
Lecture 6-cs648 Randomized Algorithms
Anshul 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 computing
jayavignesh86
 
Algorithm defination, design & Implementation
Algorithm defination, design & ImplementationAlgorithm defination, design & Implementation
Algorithm defination, design & Implementation
Bilal Maqbool ツ
 
03 algorithm properties
03 algorithm properties03 algorithm properties
03 algorithm properties
Lincoln School
 
Aad introduction
Aad introductionAad introduction
Aad introduction
Mr SMAK
 
Algorithm Design Presentation
Algorithm Design PresentationAlgorithm Design Presentation
Algorithm Design Presentation
Kawsar Ahmed
 
Algorithmic problem solving
Algorithmic problem solvingAlgorithmic problem solving
Algorithmic problem solving
Prabhakaran V M
 
Lecture 1 objective and course plan
Lecture 1   objective and course planLecture 1   objective and course plan
Lecture 1 objective and course plan
jayavignesh86
 
Dynamic programming 2
Dynamic programming 2Dynamic programming 2
Dynamic programming 2
Roy 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 Algoritma
Ajeng Savitri
 
Dynamic Programming
Dynamic ProgrammingDynamic Programming
Dynamic Programming
paramalways
 
Unit 1-problem solving with algorithm
Unit 1-problem solving with algorithmUnit 1-problem solving with algorithm
Unit 1-problem solving with algorithm
rajkumar1631010038
 
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 algo
AttaullahRahimoon
 

Viewers also liked (20)

Introduction to programming01
Introduction to programming01Introduction to programming01
Introduction to programming01
Nadim Ahmed
 
The Burrows-Wheeler Algorithm
The Burrows-Wheeler AlgorithmThe Burrows-Wheeler Algorithm
The Burrows-Wheeler Algorithm
Mustafa Salam
 
Intro To Programming Concepts
Intro To Programming ConceptsIntro To Programming Concepts
Intro To Programming Concepts
Jussi Pohjolainen
 
Lect 1. introduction to programming languages
Lect 1. introduction to programming languagesLect 1. introduction to programming languages
Lect 1. introduction to programming languages
Varun Garg
 
Programming Fundamentals
Programming FundamentalsProgramming Fundamentals
Programming Fundamentals
Hassan293
 
Chapter 1 - An Introduction to Programming
Chapter 1 - An Introduction to ProgrammingChapter 1 - An Introduction to Programming
Chapter 1 - An Introduction to Programming
mshellman
 
test1
test1test1
test1
Shodhan Kini
 
Introduction to Algorithms & flow charts
Introduction to Algorithms & flow chartsIntroduction to Algorithms & flow charts
Introduction to Algorithms & flow charts
Yash Gupta
 
Ch 8 introduction to data structures
Ch 8 introduction to data structuresCh 8 introduction to data structures
Ch 8 introduction to data structures
Chaffey College
 
Introduction to basic programming
Introduction to basic programmingIntroduction to basic programming
Introduction to basic programming
Jordan Delacruz
 
Learn Data Structures With Myassignmenthelp.Net
Learn Data Structures With Myassignmenthelp.NetLearn Data Structures With Myassignmenthelp.Net
Learn Data Structures With Myassignmenthelp.Net
Steve Johnson
 
Computer Programming: Chapter 1
Computer Programming: Chapter 1Computer Programming: Chapter 1
Computer Programming: Chapter 1
Atit Patumvan
 
Introduction to-programming
Introduction to-programmingIntroduction to-programming
Introduction to-programming
BG Java EE Course
 
Algorithms - Introduction to computer programming
Algorithms - Introduction to computer programmingAlgorithms - Introduction to computer programming
Algorithms - Introduction to computer programming
baabtra.com - No. 1 supplier of quality freshers
 
SSL12 Entropy
SSL12 EntropySSL12 Entropy
SSL12 Entropy
Keith Vaugh
 
Arithmetic Coding
Arithmetic CodingArithmetic Coding
Arithmetic Coding
anithabalaprabhu
 
Chap 1 c++
Chap 1 c++Chap 1 c++
Chap 1 c++
Widad Jamaluddin
 
Introduction to computer programming
Introduction to computer programmingIntroduction to computer programming
Introduction to computer programming
Noel Malle
 
Entropy
EntropyEntropy
Entropy
Krushal Kakadia
 
Introduction to data structures and Algorithm
Introduction to data structures and AlgorithmIntroduction to data structures and Algorithm
Introduction to data structures and Algorithm
Dhaval Kaneria
 
Introduction to programming01
Introduction to programming01Introduction to programming01
Introduction to programming01
Nadim Ahmed
 
The Burrows-Wheeler Algorithm
The Burrows-Wheeler AlgorithmThe Burrows-Wheeler Algorithm
The Burrows-Wheeler Algorithm
Mustafa Salam
 
Intro To Programming Concepts
Intro To Programming ConceptsIntro To Programming Concepts
Intro To Programming Concepts
Jussi Pohjolainen
 
Lect 1. introduction to programming languages
Lect 1. introduction to programming languagesLect 1. introduction to programming languages
Lect 1. introduction to programming languages
Varun Garg
 
Programming Fundamentals
Programming FundamentalsProgramming Fundamentals
Programming Fundamentals
Hassan293
 
Chapter 1 - An Introduction to Programming
Chapter 1 - An Introduction to ProgrammingChapter 1 - An Introduction to Programming
Chapter 1 - An Introduction to Programming
mshellman
 
Introduction to Algorithms & flow charts
Introduction to Algorithms & flow chartsIntroduction to Algorithms & flow charts
Introduction to Algorithms & flow charts
Yash Gupta
 
Ch 8 introduction to data structures
Ch 8 introduction to data structuresCh 8 introduction to data structures
Ch 8 introduction to data structures
Chaffey College
 
Introduction to basic programming
Introduction to basic programmingIntroduction to basic programming
Introduction to basic programming
Jordan Delacruz
 
Learn Data Structures With Myassignmenthelp.Net
Learn Data Structures With Myassignmenthelp.NetLearn Data Structures With Myassignmenthelp.Net
Learn Data Structures With Myassignmenthelp.Net
Steve Johnson
 
Computer Programming: Chapter 1
Computer Programming: Chapter 1Computer Programming: Chapter 1
Computer Programming: Chapter 1
Atit Patumvan
 
Introduction to computer programming
Introduction to computer programmingIntroduction to computer programming
Introduction to computer programming
Noel Malle
 
Introduction to data structures and Algorithm
Introduction to data structures and AlgorithmIntroduction to data structures and Algorithm
Introduction to data structures and Algorithm
Dhaval Kaneria
 
Ad

Similar to Introduction to algorithn class 1 (20)

DAA 1 ppt.pptx
DAA 1 ppt.pptxDAA 1 ppt.pptx
DAA 1 ppt.pptx
RAJESH S
 
DAA ppt.pptx
DAA ppt.pptxDAA ppt.pptx
DAA ppt.pptx
RAJESH S
 
Design and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptxDesign and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptx
Syed Zaid Irshad
 
Design and Analysis of Algorithm for II year Computer science and Engineering...
Design and Analysis of Algorithm for II year Computer science and Engineering...Design and Analysis of Algorithm for II year Computer science and Engineering...
Design and Analysis of Algorithm for II year Computer science and Engineering...
Kalpana Devi M
 
Algorithms & Complexity Calculation
Algorithms & Complexity CalculationAlgorithms & Complexity Calculation
Algorithms & Complexity Calculation
Akhil Kaushik
 
Analysis and Design of Algorithms
Analysis and Design of AlgorithmsAnalysis and Design of Algorithms
Analysis and Design of Algorithms
Bulbul Agrawal
 
ADA_Module 1_MN.pptx- Analysis and design of Algorithms
ADA_Module 1_MN.pptx- Analysis and design of AlgorithmsADA_Module 1_MN.pptx- Analysis and design of Algorithms
ADA_Module 1_MN.pptx- Analysis and design of Algorithms
madhu614742
 
Unit 1, ADA.pptx
Unit 1, ADA.pptxUnit 1, ADA.pptx
Unit 1, ADA.pptx
jinkhatima
 
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
 
Introduction to analysis algorithm in computer Science
Introduction to analysis algorithm in computer ScienceIntroduction to analysis algorithm in computer Science
Introduction to analysis algorithm in computer Science
tissandavid
 
introduction to analysis of algorithm in computer science
introduction to analysis of algorithm in computer scienceintroduction to analysis of algorithm in computer science
introduction to analysis of algorithm in computer science
tissandavid
 
Part 1.ppt
Part 1.pptPart 1.ppt
Part 1.ppt
RAJESH S
 
Design and analysis of algorithms Module-I.pptx
Design and analysis of algorithms Module-I.pptxDesign and analysis of algorithms Module-I.pptx
Design and analysis of algorithms Module-I.pptx
DhanushreeAN1
 
Introduction to Algorithms Complexity Analysis
Introduction to Algorithms Complexity Analysis Introduction to Algorithms Complexity Analysis
Introduction to Algorithms Complexity Analysis
Dr. Pankaj Agarwal
 
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
rajesshs31r
 
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
rajesshs31r
 
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
Tekle12
 
Chapter1.1 Introduction.ppt
Chapter1.1 Introduction.pptChapter1.1 Introduction.ppt
Chapter1.1 Introduction.ppt
Tekle12
 
Analysis of Algorithm DAA notes Part 1.ppt
Analysis of Algorithm DAA notes Part 1.pptAnalysis of Algorithm DAA notes Part 1.ppt
Analysis of Algorithm DAA notes Part 1.ppt
RAJESH S
 
Analysis of Algorithm Part one analysis.ppt
Analysis of Algorithm Part one analysis.pptAnalysis of Algorithm Part one analysis.ppt
Analysis of Algorithm Part one analysis.ppt
RAJESH S
 
DAA 1 ppt.pptx
DAA 1 ppt.pptxDAA 1 ppt.pptx
DAA 1 ppt.pptx
RAJESH S
 
DAA ppt.pptx
DAA ppt.pptxDAA ppt.pptx
DAA ppt.pptx
RAJESH S
 
Design and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptxDesign and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptx
Syed Zaid Irshad
 
Design and Analysis of Algorithm for II year Computer science and Engineering...
Design and Analysis of Algorithm for II year Computer science and Engineering...Design and Analysis of Algorithm for II year Computer science and Engineering...
Design and Analysis of Algorithm for II year Computer science and Engineering...
Kalpana Devi M
 
Algorithms & Complexity Calculation
Algorithms & Complexity CalculationAlgorithms & Complexity Calculation
Algorithms & Complexity Calculation
Akhil Kaushik
 
Analysis and Design of Algorithms
Analysis and Design of AlgorithmsAnalysis and Design of Algorithms
Analysis and Design of Algorithms
Bulbul Agrawal
 
ADA_Module 1_MN.pptx- Analysis and design of Algorithms
ADA_Module 1_MN.pptx- Analysis and design of AlgorithmsADA_Module 1_MN.pptx- Analysis and design of Algorithms
ADA_Module 1_MN.pptx- Analysis and design of Algorithms
madhu614742
 
Unit 1, ADA.pptx
Unit 1, ADA.pptxUnit 1, ADA.pptx
Unit 1, ADA.pptx
jinkhatima
 
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
 
Introduction to analysis algorithm in computer Science
Introduction to analysis algorithm in computer ScienceIntroduction to analysis algorithm in computer Science
Introduction to analysis algorithm in computer Science
tissandavid
 
introduction to analysis of algorithm in computer science
introduction to analysis of algorithm in computer scienceintroduction to analysis of algorithm in computer science
introduction to analysis of algorithm in computer science
tissandavid
 
Part 1.ppt
Part 1.pptPart 1.ppt
Part 1.ppt
RAJESH S
 
Design and analysis of algorithms Module-I.pptx
Design and analysis of algorithms Module-I.pptxDesign and analysis of algorithms Module-I.pptx
Design and analysis of algorithms Module-I.pptx
DhanushreeAN1
 
Introduction to Algorithms Complexity Analysis
Introduction to Algorithms Complexity Analysis Introduction to Algorithms Complexity Analysis
Introduction to Algorithms Complexity Analysis
Dr. Pankaj Agarwal
 
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
rajesshs31r
 
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
rajesshs31r
 
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
Tekle12
 
Chapter1.1 Introduction.ppt
Chapter1.1 Introduction.pptChapter1.1 Introduction.ppt
Chapter1.1 Introduction.ppt
Tekle12
 
Analysis of Algorithm DAA notes Part 1.ppt
Analysis of Algorithm DAA notes Part 1.pptAnalysis of Algorithm DAA notes Part 1.ppt
Analysis of Algorithm DAA notes Part 1.ppt
RAJESH S
 
Analysis of Algorithm Part one analysis.ppt
Analysis of Algorithm Part one analysis.pptAnalysis of Algorithm Part one analysis.ppt
Analysis of Algorithm Part one analysis.ppt
RAJESH S
 
Ad

More from Kumar (20)

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

Recently uploaded (20)

How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18
Celine George
 
MEDICAL BIOLOGY MCQS BY. DR NASIR MUSTAFA
MEDICAL BIOLOGY MCQS  BY. DR NASIR MUSTAFAMEDICAL BIOLOGY MCQS  BY. DR NASIR MUSTAFA
MEDICAL BIOLOGY MCQS BY. DR NASIR MUSTAFA
Dr. Nasir Mustafa
 
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
parmarjuli1412
 
CNS infections (encephalitis, meningitis & Brain abscess
CNS infections (encephalitis, meningitis & Brain abscessCNS infections (encephalitis, meningitis & Brain abscess
CNS infections (encephalitis, meningitis & Brain abscess
Mohamed Rizk Khodair
 
The History of Kashmir Karkota Dynasty NEP.pptx
The History of Kashmir Karkota Dynasty NEP.pptxThe History of Kashmir Karkota Dynasty NEP.pptx
The History of Kashmir Karkota Dynasty NEP.pptx
Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
Search Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo SlidesSearch Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo Slides
Celine George
 
Transform tomorrow: Master benefits analysis with Gen AI today webinar, 30 A...
Transform tomorrow: Master benefits analysis with Gen AI today webinar,  30 A...Transform tomorrow: Master benefits analysis with Gen AI today webinar,  30 A...
Transform tomorrow: Master benefits analysis with Gen AI today webinar, 30 A...
Association for Project Management
 
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptxANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
Mayuri Chavan
 
Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)
Mohamed Rizk Khodair
 
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
Dr. Nasir Mustafa
 
What is the Philosophy of Statistics? (and how I was drawn to it)
What is the Philosophy of Statistics? (and how I was drawn to it)What is the Philosophy of Statistics? (and how I was drawn to it)
What is the Philosophy of Statistics? (and how I was drawn to it)
jemille6
 
Classification of mental disorder in 5th semester bsc. nursing and also used ...
Classification of mental disorder in 5th semester bsc. nursing and also used ...Classification of mental disorder in 5th semester bsc. nursing and also used ...
Classification of mental disorder in 5th semester bsc. nursing and also used ...
parmarjuli1412
 
Botany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic ExcellenceBotany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic Excellence
online college homework help
 
Origin of Brahmi script: A breaking down of various theories
Origin of Brahmi script: A breaking down of various theoriesOrigin of Brahmi script: A breaking down of various theories
Origin of Brahmi script: A breaking down of various theories
PrachiSontakke5
 
Overview Well-Being and Creative Careers
Overview Well-Being and Creative CareersOverview Well-Being and Creative Careers
Overview Well-Being and Creative Careers
University of Amsterdam
 
Chemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptxChemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptx
Mayuri Chavan
 
Cultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptxCultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptx
UmeshTimilsina1
 
spinal cord disorders (Myelopathies and radiculoapthies)
spinal cord disorders (Myelopathies and radiculoapthies)spinal cord disorders (Myelopathies and radiculoapthies)
spinal cord disorders (Myelopathies and radiculoapthies)
Mohamed Rizk Khodair
 
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
Celine George
 
How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18
Celine George
 
MEDICAL BIOLOGY MCQS BY. DR NASIR MUSTAFA
MEDICAL BIOLOGY MCQS  BY. DR NASIR MUSTAFAMEDICAL BIOLOGY MCQS  BY. DR NASIR MUSTAFA
MEDICAL BIOLOGY MCQS BY. DR NASIR MUSTAFA
Dr. Nasir Mustafa
 
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
parmarjuli1412
 
CNS infections (encephalitis, meningitis & Brain abscess
CNS infections (encephalitis, meningitis & Brain abscessCNS infections (encephalitis, meningitis & Brain abscess
CNS infections (encephalitis, meningitis & Brain abscess
Mohamed Rizk Khodair
 
Search Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo SlidesSearch Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo Slides
Celine George
 
Transform tomorrow: Master benefits analysis with Gen AI today webinar, 30 A...
Transform tomorrow: Master benefits analysis with Gen AI today webinar,  30 A...Transform tomorrow: Master benefits analysis with Gen AI today webinar,  30 A...
Transform tomorrow: Master benefits analysis with Gen AI today webinar, 30 A...
Association for Project Management
 
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptxANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
Mayuri Chavan
 
Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)
Mohamed Rizk Khodair
 
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
Dr. Nasir Mustafa
 
What is the Philosophy of Statistics? (and how I was drawn to it)
What is the Philosophy of Statistics? (and how I was drawn to it)What is the Philosophy of Statistics? (and how I was drawn to it)
What is the Philosophy of Statistics? (and how I was drawn to it)
jemille6
 
Classification of mental disorder in 5th semester bsc. nursing and also used ...
Classification of mental disorder in 5th semester bsc. nursing and also used ...Classification of mental disorder in 5th semester bsc. nursing and also used ...
Classification of mental disorder in 5th semester bsc. nursing and also used ...
parmarjuli1412
 
Botany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic ExcellenceBotany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic Excellence
online college homework help
 
Origin of Brahmi script: A breaking down of various theories
Origin of Brahmi script: A breaking down of various theoriesOrigin of Brahmi script: A breaking down of various theories
Origin of Brahmi script: A breaking down of various theories
PrachiSontakke5
 
Overview Well-Being and Creative Careers
Overview Well-Being and Creative CareersOverview Well-Being and Creative Careers
Overview Well-Being and Creative Careers
University of Amsterdam
 
Chemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptxChemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptx
Mayuri Chavan
 
Cultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptxCultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptx
UmeshTimilsina1
 
spinal cord disorders (Myelopathies and radiculoapthies)
spinal cord disorders (Myelopathies and radiculoapthies)spinal cord disorders (Myelopathies and radiculoapthies)
spinal cord disorders (Myelopathies and radiculoapthies)
Mohamed Rizk Khodair
 
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
Celine George
 

Introduction to algorithn class 1

  • 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
  翻译: