SlideShare a Scribd company logo
1 of 19
CSE 5311
DESIGN AND
ANALYSIS OF
ALGORITHMS
Definitions of Algorithm
 A mathematical relation between an observed quantity
and a variable used in a step-by-step mathematical
process to calculate a quantity
 Algorithm is any well defined computational procedure
that takes some value or set of values as input and
produces some value or set of values as output
 A procedure for solving a mathematical problem in a
finite number of steps that frequently involves repetition
of an operation; broadly : a step-by-step procedure for
solving a problem or accomplishing some end
(Webster‟s Dictionary)
Analysis of Algorithms
Involves evaluating the
following parameters
 Memory – Unit generalized as
“WORDS”
 Computer time – Unit generalized as
“CYCLES”
 Correctness – Producing the desired
output
Sample Algorithm
FINDING LARGEST NUMBER
INPUT: unsorted array „A[n]‟of n numbers
OUTPUT: largest number
----------------------------------------------------------
1 large ← A[j]
2 for j ← 2 to length[A]
3 if large < A[j]
4 large ← A[j]
5 end
Space and Time Analysis
(Largest Number Scan Algorithm)
SPACE S(n): One “word” is required to run the
algorithm (step 1…to store variable „large‟)
TIME T(n): n-1 comparisons are required to find
the largest (every comparison takes one cycle)
*Aim is to reduce both T(n) and S(n)
ASYMPTOTICS
Used to formalize that an algorithm has
running time or storage requirements that
are ``never more than,'' ``always greater
than,'' or ``exactly'' some amount
ASYMPTOTICS NOTATIONS
O-notation (Big Oh)
 Asymptotic Upper Bound
 For a given function g(n), we denote O(g(n)) as the set of
functions:
O(g(n)) = { f(n)| there exists positive
constants c and n0 such that
0 ≤ f(n) ≤ c g(n) for all n ≥ n0 }
ASYMPTOTICS NOTATIONS
Θ-notation
 Asymptotic tight bound
 Θ (g(n)) represents a set of functions such
that:
Θ (g(n)) = {f(n): there exist positive
constants c1, c2, and n0 such
that 0 ≤ c1g(n) ≤ f(n) ≤ c2g(n)
for all n≥ n0}
ASYMPTOTICS NOTATIONS
Ω-notation
 Asymptotic lower bound
 Ω (g(n)) represents a set of functions such
that:
Ω(g(n)) = {f(n): there exist positive
constants c and n0 such that
0 ≤ c g(n) ≤ f(n) for all n≥ n0}
 O-notation ------------------
 Θ-notation ------------------
 Ω-notation ------------------
Less than equal to (“≤”)
Equal to (“=“)
Greater than equal to
(“≥”)
Mappings for n2
Ω (n2 )
O(n2 )
Θ(n2)
Bounds of a Function
Cntd…
Cntd…
 c1 , c2 & n0 -> constants
 T(n) exists between c1n & c2n
 Below n0 we do not plot T(n)
 T(n) becomes significant only above n0
Common plots of O( )
O(2n)
O(n3 )
O(n2)
O(nlogn)
O(n)
O(√n)
O(logn)
O(1)
Examples of algorithms for sorting
techniques and their complexities
 Insertion sort : O(n2)
 Selection sort : O(n2)
 Quick sort : O(n logn)
 Merge sort : O(n logn)
RECURRENCE RELATIONS
 A Recurrence is an equation or inequality
that describes a function in terms of its
value on smaller inputs
 Special techniques are required to analyze
the space and time required
RECURRENCE RELATIONS
EXAMPLE
EXAMPLE 1: QUICK SORT
T(n)= 2T(n/2) + O(n)
T(1)= O(1)
 In the above case the presence of function of T on both
sides of the equation signifies the presence of
recurrence relation
 (SUBSTITUTION MEATHOD used) The equations are
simplified to produce the final result:
……cntd
T(n) = 2T(n/2) + O(n)
= 2(2(n/22) + (n/2)) + n
= 22 T(n/22) + n + n
= 22 (T(n/23)+ (n/22)) + n + n
= 23 T(n/23) + n + n + n
= n log n
Cntd….
Cntd…
EXAMPLE 2: BINARY SEARCH
T(n)=O(1) + T(n/2)
T(1)=1
Above is another example of recurrence relation and the way to solve it
is by Substitution.
T(n)=T(n/2) +1
= T(n/22)+1+1
= T(n/23)+1+1+1
= logn
T(n)= O(logn)

More Related Content

What's hot

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
 
Algorithms Lecture 2: Analysis of Algorithms I
Algorithms Lecture 2: Analysis of Algorithms IAlgorithms Lecture 2: Analysis of Algorithms I
Algorithms Lecture 2: Analysis of Algorithms IMohamed Loey
 
Algorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsAlgorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsMohamed Loey
 
Mathematical Analysis of Recursive Algorithm.
Mathematical Analysis of Recursive Algorithm.Mathematical Analysis of Recursive Algorithm.
Mathematical Analysis of Recursive Algorithm.mohanrathod18
 
Design and Analysis of Algorithms
Design and Analysis of AlgorithmsDesign and Analysis of Algorithms
Design and Analysis of AlgorithmsArvind Krishnaa
 
Asymptotic Notations
Asymptotic NotationsAsymptotic Notations
Asymptotic NotationsRishabh Soni
 
Time and space complexity
Time and space complexityTime and space complexity
Time and space complexityAnkit Katiyar
 
Analysis and Design of Algorithms
Analysis and Design of AlgorithmsAnalysis and Design of Algorithms
Analysis and Design of AlgorithmsBulbul Agrawal
 
Introduction to data structures and Algorithm
Introduction to data structures and AlgorithmIntroduction to data structures and Algorithm
Introduction to data structures and AlgorithmDhaval Kaneria
 
Design & Analysis of Algorithms Lecture Notes
Design & Analysis of Algorithms Lecture NotesDesign & Analysis of Algorithms Lecture Notes
Design & Analysis of Algorithms Lecture NotesFellowBuddy.com
 
BackTracking Algorithm: Technique and Examples
BackTracking Algorithm: Technique and ExamplesBackTracking Algorithm: Technique and Examples
BackTracking Algorithm: Technique and ExamplesFahim Ferdous
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notationsEhtisham Ali
 

What's hot (20)

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
 
Asymptotic Notation
Asymptotic NotationAsymptotic Notation
Asymptotic Notation
 
Daa notes 1
Daa notes 1Daa notes 1
Daa notes 1
 
Asymptotic notation
Asymptotic notationAsymptotic notation
Asymptotic notation
 
Algorithms Lecture 2: Analysis of Algorithms I
Algorithms Lecture 2: Analysis of Algorithms IAlgorithms Lecture 2: Analysis of Algorithms I
Algorithms Lecture 2: Analysis of Algorithms I
 
Unit 1 chapter 1 Design and Analysis of Algorithms
Unit 1   chapter 1 Design and Analysis of AlgorithmsUnit 1   chapter 1 Design and Analysis of Algorithms
Unit 1 chapter 1 Design and Analysis of Algorithms
 
Algorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsAlgorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to Algorithms
 
Mathematical Analysis of Recursive Algorithm.
Mathematical Analysis of Recursive Algorithm.Mathematical Analysis of Recursive Algorithm.
Mathematical Analysis of Recursive Algorithm.
 
Design and Analysis of Algorithms
Design and Analysis of AlgorithmsDesign and Analysis of Algorithms
Design and Analysis of Algorithms
 
Divide and conquer
Divide and conquerDivide and conquer
Divide and conquer
 
Asymptotic Notations
Asymptotic NotationsAsymptotic Notations
Asymptotic Notations
 
Time and space complexity
Time and space complexityTime and space complexity
Time and space complexity
 
Daa unit 1
Daa unit 1Daa unit 1
Daa unit 1
 
Randomized algorithms ver 1.0
Randomized algorithms ver 1.0Randomized algorithms ver 1.0
Randomized algorithms ver 1.0
 
Analysis and Design of Algorithms
Analysis and Design of AlgorithmsAnalysis and Design of Algorithms
Analysis and Design of Algorithms
 
Introduction to data structures and Algorithm
Introduction to data structures and AlgorithmIntroduction to data structures and Algorithm
Introduction to data structures and Algorithm
 
Design & Analysis of Algorithms Lecture Notes
Design & Analysis of Algorithms Lecture NotesDesign & Analysis of Algorithms Lecture Notes
Design & Analysis of Algorithms Lecture Notes
 
BackTracking Algorithm: Technique and Examples
BackTracking Algorithm: Technique and ExamplesBackTracking Algorithm: Technique and Examples
BackTracking Algorithm: Technique and Examples
 
Greedy Algorihm
Greedy AlgorihmGreedy Algorihm
Greedy Algorihm
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
 

Viewers also liked

Genetic Algorithm based Approach to solve Non-Fractional (0/1) Knapsack Optim...
Genetic Algorithm based Approach to solve Non-Fractional (0/1) Knapsack Optim...Genetic Algorithm based Approach to solve Non-Fractional (0/1) Knapsack Optim...
Genetic Algorithm based Approach to solve Non-Fractional (0/1) Knapsack Optim...International Islamic University
 
Knapsack problem using dynamic programming
Knapsack problem using dynamic programmingKnapsack problem using dynamic programming
Knapsack problem using dynamic programmingkhush_boo31
 
0 1 knapsack problem using dynamic programming
0 1 knapsack problem using dynamic programming0 1 knapsack problem using dynamic programming
0 1 knapsack problem using dynamic programmingMaher Alshammari
 
01 knapsack using backtracking
01 knapsack using backtracking01 knapsack using backtracking
01 knapsack using backtrackingmandlapure
 
Greedy Algorithm - Knapsack Problem
Greedy Algorithm - Knapsack ProblemGreedy Algorithm - Knapsack Problem
Greedy Algorithm - Knapsack ProblemMadhu Bala
 

Viewers also liked (10)

Kruskal Algorithm
Kruskal AlgorithmKruskal Algorithm
Kruskal Algorithm
 
Genetic Algorithm based Approach to solve Non-Fractional (0/1) Knapsack Optim...
Genetic Algorithm based Approach to solve Non-Fractional (0/1) Knapsack Optim...Genetic Algorithm based Approach to solve Non-Fractional (0/1) Knapsack Optim...
Genetic Algorithm based Approach to solve Non-Fractional (0/1) Knapsack Optim...
 
Knapsack problem using dynamic programming
Knapsack problem using dynamic programmingKnapsack problem using dynamic programming
Knapsack problem using dynamic programming
 
0 1 knapsack problem using dynamic programming
0 1 knapsack problem using dynamic programming0 1 knapsack problem using dynamic programming
0 1 knapsack problem using dynamic programming
 
Knapsack problem
Knapsack problemKnapsack problem
Knapsack problem
 
01 knapsack using backtracking
01 knapsack using backtracking01 knapsack using backtracking
01 knapsack using backtracking
 
Knapsack
KnapsackKnapsack
Knapsack
 
Knapsack Problem
Knapsack ProblemKnapsack Problem
Knapsack Problem
 
Greedy Algorithm - Knapsack Problem
Greedy Algorithm - Knapsack ProblemGreedy Algorithm - Knapsack Problem
Greedy Algorithm - Knapsack Problem
 
Knapsack problem using fixed tuple
Knapsack problem using fixed tupleKnapsack problem using fixed tuple
Knapsack problem using fixed tuple
 

Similar to DESIGN AND ANALYSIS OF ALGORITHMS

Asymptotic Notation and Complexity
Asymptotic Notation and ComplexityAsymptotic Notation and Complexity
Asymptotic Notation and ComplexityRajandeep Gill
 
Anlysis and design of algorithms part 1
Anlysis and design of algorithms part 1Anlysis and design of algorithms part 1
Anlysis and design of algorithms part 1Deepak John
 
Design and analysis of algorithm ppt ppt
Design and analysis of algorithm ppt pptDesign and analysis of algorithm ppt ppt
Design and analysis of algorithm ppt pptsrushtiivp
 
Lecture 2 data structures and algorithms
Lecture 2 data structures and algorithmsLecture 2 data structures and algorithms
Lecture 2 data structures and algorithmsAakash deep Singhal
 
Advanced Datastructures and algorithms CP4151unit1b.pdf
Advanced Datastructures and algorithms CP4151unit1b.pdfAdvanced Datastructures and algorithms CP4151unit1b.pdf
Advanced Datastructures and algorithms CP4151unit1b.pdfSheba41
 
Asymptotic analysis
Asymptotic analysisAsymptotic analysis
Asymptotic analysisSoujanya V
 
Dr hasany 2467_16649_1_lec-2-zabist
Dr hasany 2467_16649_1_lec-2-zabistDr hasany 2467_16649_1_lec-2-zabist
Dr hasany 2467_16649_1_lec-2-zabistGatewayggg Testeru
 
Algorithm And analysis Lecture 03& 04-time complexity.
 Algorithm And analysis Lecture 03& 04-time complexity. Algorithm And analysis Lecture 03& 04-time complexity.
Algorithm And analysis Lecture 03& 04-time complexity.Tariq Khan
 
04. Growth_Rate_AND_Asymptotic Notations_.pptx
04. Growth_Rate_AND_Asymptotic Notations_.pptx04. Growth_Rate_AND_Asymptotic Notations_.pptx
04. Growth_Rate_AND_Asymptotic Notations_.pptxarslanzaheer14
 
2-AnalysisOfAlgs.ppt
2-AnalysisOfAlgs.ppt2-AnalysisOfAlgs.ppt
2-AnalysisOfAlgs.pptTahseenEjaz3
 
Daa unit 6_efficiency of algorithms
Daa unit 6_efficiency of algorithmsDaa unit 6_efficiency of algorithms
Daa unit 6_efficiency of algorithmssnehajiyani
 
Cs6402 design and analysis of algorithms may june 2016 answer key
Cs6402 design and analysis of algorithms may june 2016 answer keyCs6402 design and analysis of algorithms may june 2016 answer key
Cs6402 design and analysis of algorithms may june 2016 answer keyappasami
 
Lec03 04-time complexity
Lec03 04-time complexityLec03 04-time complexity
Lec03 04-time complexityAbbas Ali
 

Similar to DESIGN AND ANALYSIS OF ALGORITHMS (20)

Lec1
Lec1Lec1
Lec1
 
Asymptotic Notation and Complexity
Asymptotic Notation and ComplexityAsymptotic Notation and Complexity
Asymptotic Notation and Complexity
 
Anlysis and design of algorithms part 1
Anlysis and design of algorithms part 1Anlysis and design of algorithms part 1
Anlysis and design of algorithms part 1
 
AsymptoticAnalysis.ppt
AsymptoticAnalysis.pptAsymptoticAnalysis.ppt
AsymptoticAnalysis.ppt
 
Design and analysis of algorithm ppt ppt
Design and analysis of algorithm ppt pptDesign and analysis of algorithm ppt ppt
Design and analysis of algorithm ppt ppt
 
Annotations.pdf
Annotations.pdfAnnotations.pdf
Annotations.pdf
 
Lecture 2 data structures and algorithms
Lecture 2 data structures and algorithmsLecture 2 data structures and algorithms
Lecture 2 data structures and algorithms
 
Advanced Datastructures and algorithms CP4151unit1b.pdf
Advanced Datastructures and algorithms CP4151unit1b.pdfAdvanced Datastructures and algorithms CP4151unit1b.pdf
Advanced Datastructures and algorithms CP4151unit1b.pdf
 
1.algorithms
1.algorithms1.algorithms
1.algorithms
 
Asymptotic analysis
Asymptotic analysisAsymptotic analysis
Asymptotic analysis
 
Dr hasany 2467_16649_1_lec-2-zabist
Dr hasany 2467_16649_1_lec-2-zabistDr hasany 2467_16649_1_lec-2-zabist
Dr hasany 2467_16649_1_lec-2-zabist
 
Algorithm And analysis Lecture 03& 04-time complexity.
 Algorithm And analysis Lecture 03& 04-time complexity. Algorithm And analysis Lecture 03& 04-time complexity.
Algorithm And analysis Lecture 03& 04-time complexity.
 
04. Growth_Rate_AND_Asymptotic Notations_.pptx
04. Growth_Rate_AND_Asymptotic Notations_.pptx04. Growth_Rate_AND_Asymptotic Notations_.pptx
04. Growth_Rate_AND_Asymptotic Notations_.pptx
 
2-AnalysisOfAlgs.ppt
2-AnalysisOfAlgs.ppt2-AnalysisOfAlgs.ppt
2-AnalysisOfAlgs.ppt
 
Daa unit 6_efficiency of algorithms
Daa unit 6_efficiency of algorithmsDaa unit 6_efficiency of algorithms
Daa unit 6_efficiency of algorithms
 
Cs6402 design and analysis of algorithms may june 2016 answer key
Cs6402 design and analysis of algorithms may june 2016 answer keyCs6402 design and analysis of algorithms may june 2016 answer key
Cs6402 design and analysis of algorithms may june 2016 answer key
 
Lec03 04-time complexity
Lec03 04-time complexityLec03 04-time complexity
Lec03 04-time complexity
 
3 analysis.gtm
3 analysis.gtm3 analysis.gtm
3 analysis.gtm
 
Algorithm.ppt
Algorithm.pptAlgorithm.ppt
Algorithm.ppt
 
Asymptotic Notation
Asymptotic NotationAsymptotic Notation
Asymptotic Notation
 

Recently uploaded

Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...Call Girls in Nagpur High Profile
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringmulugeta48
 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Bookingroncy bisnoi
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VDineshKumar4165
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Christo Ananth
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdfKamal Acharya
 
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICSUNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICSrknatarajan
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdfankushspencer015
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . pptDineshKumar4165
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptDineshKumar4165
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfKamal Acharya
 

Recently uploaded (20)

Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICSUNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
 
NFPA 5000 2024 standard .
NFPA 5000 2024 standard                                  .NFPA 5000 2024 standard                                  .
NFPA 5000 2024 standard .
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 

DESIGN AND ANALYSIS OF ALGORITHMS

  • 2. Definitions of Algorithm  A mathematical relation between an observed quantity and a variable used in a step-by-step mathematical process to calculate a quantity  Algorithm is any well defined computational procedure that takes some value or set of values as input and produces some value or set of values as output  A procedure for solving a mathematical problem in a finite number of steps that frequently involves repetition of an operation; broadly : a step-by-step procedure for solving a problem or accomplishing some end (Webster‟s Dictionary)
  • 3. Analysis of Algorithms Involves evaluating the following parameters  Memory – Unit generalized as “WORDS”  Computer time – Unit generalized as “CYCLES”  Correctness – Producing the desired output
  • 4. Sample Algorithm FINDING LARGEST NUMBER INPUT: unsorted array „A[n]‟of n numbers OUTPUT: largest number ---------------------------------------------------------- 1 large ← A[j] 2 for j ← 2 to length[A] 3 if large < A[j] 4 large ← A[j] 5 end
  • 5. Space and Time Analysis (Largest Number Scan Algorithm) SPACE S(n): One “word” is required to run the algorithm (step 1…to store variable „large‟) TIME T(n): n-1 comparisons are required to find the largest (every comparison takes one cycle) *Aim is to reduce both T(n) and S(n)
  • 6. ASYMPTOTICS Used to formalize that an algorithm has running time or storage requirements that are ``never more than,'' ``always greater than,'' or ``exactly'' some amount
  • 7. ASYMPTOTICS NOTATIONS O-notation (Big Oh)  Asymptotic Upper Bound  For a given function g(n), we denote O(g(n)) as the set of functions: O(g(n)) = { f(n)| there exists positive constants c and n0 such that 0 ≤ f(n) ≤ c g(n) for all n ≥ n0 }
  • 8. ASYMPTOTICS NOTATIONS Θ-notation  Asymptotic tight bound  Θ (g(n)) represents a set of functions such that: Θ (g(n)) = {f(n): there exist positive constants c1, c2, and n0 such that 0 ≤ c1g(n) ≤ f(n) ≤ c2g(n) for all n≥ n0}
  • 9. ASYMPTOTICS NOTATIONS Ω-notation  Asymptotic lower bound  Ω (g(n)) represents a set of functions such that: Ω(g(n)) = {f(n): there exist positive constants c and n0 such that 0 ≤ c g(n) ≤ f(n) for all n≥ n0}
  • 10.  O-notation ------------------  Θ-notation ------------------  Ω-notation ------------------ Less than equal to (“≤”) Equal to (“=“) Greater than equal to (“≥”)
  • 11. Mappings for n2 Ω (n2 ) O(n2 ) Θ(n2)
  • 12. Bounds of a Function Cntd…
  • 13. Cntd…  c1 , c2 & n0 -> constants  T(n) exists between c1n & c2n  Below n0 we do not plot T(n)  T(n) becomes significant only above n0
  • 14. Common plots of O( ) O(2n) O(n3 ) O(n2) O(nlogn) O(n) O(√n) O(logn) O(1)
  • 15. Examples of algorithms for sorting techniques and their complexities  Insertion sort : O(n2)  Selection sort : O(n2)  Quick sort : O(n logn)  Merge sort : O(n logn)
  • 16. RECURRENCE RELATIONS  A Recurrence is an equation or inequality that describes a function in terms of its value on smaller inputs  Special techniques are required to analyze the space and time required
  • 17. RECURRENCE RELATIONS EXAMPLE EXAMPLE 1: QUICK SORT T(n)= 2T(n/2) + O(n) T(1)= O(1)  In the above case the presence of function of T on both sides of the equation signifies the presence of recurrence relation  (SUBSTITUTION MEATHOD used) The equations are simplified to produce the final result: ……cntd
  • 18. T(n) = 2T(n/2) + O(n) = 2(2(n/22) + (n/2)) + n = 22 T(n/22) + n + n = 22 (T(n/23)+ (n/22)) + n + n = 23 T(n/23) + n + n + n = n log n Cntd….
  • 19. Cntd… EXAMPLE 2: BINARY SEARCH T(n)=O(1) + T(n/2) T(1)=1 Above is another example of recurrence relation and the way to solve it is by Substitution. T(n)=T(n/2) +1 = T(n/22)+1+1 = T(n/23)+1+1+1 = logn T(n)= O(logn)