SlideShare a Scribd company logo
1 of 27
Introduction to
Analysis & Design of Algorithm
Submitted by:
Prof. Bulbul Agrawal
Assistant Professor
Department of Computer Science & Engineering and Information Technology
Content
• Terminologies
• Course Objective
• Skeleton of the ADA
• Introduction to ADA
• Asymptotic Notations
• Algorithm Design Techniques
Terminologies:
• Algorithm Design:
Methods for designing efficient algorithms.
• Algorithm Analysis:
Analysis of resource usage of given algorithms. (Time & Space)
Why do we study this subject?
• Efficient algorithms lead to efficient programs.
• Efficient programs sell better.
• Efficient programs make better used of hardware.
• Programmers who write efficient programs are preferred.
Course Objective:
• The data structure includes analyzing various algorithms along with time and space
complexities. It also helps students to design new algorithms through mathematical
analysis and programming.
Skeleton of ADA:
ADA
Unit:1
Divide and
Conquer
Unit:2
Greedy
Strategy
Unit:3
Dynamic
Programming
Unit:4
Backtracking
and Branch &
Bound
Unit:5
Graphs and
Trees
Introduction:
• The set of rules that define how a particular problem can be solved in finite number of
steps is known as algorithm.
• An algorithm is a list of steps (Sequence of unambiguous instructions) for solving a
problem that transforms the input into the output.
Problem
Algorithm
Computer
Input Output
Designing of an algorithm:
Understand the problem
Decision making on:
Capabilities of computational devices
Algorithm Design Techniques
Data Structures
Specification of algorithms
Analysis of algorithm
Algorithm verification
Code the algorithm
Properties of an algorithm:
• An algorithm takes zero or more inputs.
• An algorithm results in one or more outputs.
• All operations can be carried out in a finite amount of time.
• An algorithm should be efficient and flexible.
• It should use less memory space as much as possible.
• An algorithm must terminate after a finite number of steps.
• Each step in the algorithm must be easily understood.
• An algorithm should be concise and compact to facilitate verification of their
correctness.
Two main tasks in the study of Algorithms:
• Algorithm Design
• Analysis of Algorithms
How to analyzed the algorithm?
Algorithm efficiency can be measured by two aspects;
Time Complexity: Given in terms of frequency count
• Instructions take time.
• How fast does the algorithm perform?
• What affects its runtime?
Space Complexity: Amount of memory required
• Data structure take space.
• What kind of data structure can be used?
• How does choice of data structure affect the runtime?
Asymptotic Notations:
 Given two algorithms for a task, how we find out which one is better?
1. It might be possible that for some inputs, first algorithm performs better than
the second. And for some inputs second performs better.
2. Or it might also be possible that for some inputs, first algorithm perform
better on one machine and the second works better on other machine for
some other inputs.
 So Asymptotic Notation is the big idea that handles above issues in analysing
algorithms. In Asymptotic Analysis, we evaluate the performance of an
algorithm in terms of input size.
 Using Asymptotic Analysis we can very well conclude the Best Case, Average
Case, and Worst Case scenario of an algorithm.
Asymptotic Notations:
• Asymptotic Notations are used to represent the complexity of an algorithm.
• Asymptotic Notations provides with a mechanism to calculate and represent
time and space complexity for any algorithm.
Order of Growth:
• Order of growth in algorithm means how the time for computation increase
when you increase the input size. It really matters when your input size is very
large.
Kind of Analysis:
Usually the time required by an algorithm falls under three types:
 Best Case: Minimum time required for algorithm execution
 Average Case: Average time required for algorithm execution
 Worst Case: Worst time required for algorithm execution
Following are the commonly used asymptotic notations to calculate the running
time complexity of an algorithm;
 O-Notation (Big-Oh Notation)
 Ω-Notation (Omega Notation)
 Θ-Notation (Theta Notation)
O-Notation (Big-Oh Notation):
• Big-O notation represents the upper bound of the running time of an algorithm.
Thus, it gives the worst-case complexity of an algorithm.
• Given two functions f(n) & g(n) for input n, we say f(n) is in O(g(n) ) iff there
exist positive constants c and n0 such that
f(n)  c g(n) for all n  n0
• Basically, we want to find a function g(n) that is
eventually always bigger than f(n).
• g(n) is an asymptotic upper bound for f(n).
Ω-Notation (Omega Notation):
• Omega notation represents the lower bound of the running time of an
algorithm. Thus, it provides the best case complexity of an algorithm.
• Given two functions f(n) & g(n) for input n, we say f(n) is in Ω(g(n) ) iff there
exist positive constants c and n0 such that
f(n)  c g(n) for all n  n0
• Basically, we want to find a function g(n) that is
eventually always smaller than f(n).
• g(n) is an asymptotic lower bound for f(n).
Θ-Notation (Theta Notation):
• Since it represents the upper and the lower bound of the running time of an
algorithm, it is used for analyzing the average-case complexity of an algorithm.
• Given two functions f(n) & g(n) for input n, we say f(n) is in Θ(g(n) ) iff there
exist positive constants C1 & C2 and n0 such that
C1 g(n)  f(n)  C2 g(n)
for all n  n0
• g(n) is an asymptotically tight bound for f(n).
Algorithm Design Strategies:
We can design an algorithm by choose the one of the following strategies:
1. Divide and Conquer
2. Greedy Algorithm
3. Dynamic programming
4. Backtracking
5. Branch and Bound
1. Divide & Conquer Strategy:
The algorithm which follows divide and conquer technique involves 3 steps:
1. Divide the original problem into a set of sub problems.
2. Conquer (or solve) every sub-problem individually, recursive.
3. Combine the solutions of these sub problems to get the solution of original
problem.
 Problems that follow divide and conquer strategy:
• Merge Sort
• Binary Search
• Strassen's Matrix Multiplication
2. Greedy Strategy:
• Greedy technique is used to solve an optimization problem. (Repeatedly do what is
best now)
• An Optimization problem is one in which, we are given a set of input values, which
are required to be either maximized or minimized (known as objective function) w.r.t.
some constraints or conditions.
• The greedy algorithm does not always guarantee the optimal solution but it generally
produces solutions that are very close in value to the optimal.
 Problems that follow greedy strategy:
• Fractional Knapsack Problem
• Minimum Spanning Tress
• Single Source Shortest Path Algorithm
• Job Sequencing With Deadline
3. Dynamic Programming:
• Dynamic programming is a technique that breaks the problems into sub-
problems, and saves the result for future purposes so that we do not need to
compute the result again.
• The subproblems are optimized to optimize the overall solution is known as
optimal substructure property.
Problems that follow dynamic strategy:
• 0/1 Knapsack
• Matrix Chain Multiplication
• Multistage Graph
4. Backtracking:
• Backtracking is an algorithmic technique for solving problems by trying to
build a solution incrementally, one piece at a time, removing those solutions
that fail to satisfy the constraints of the problem at any point
• Backtracking is not used for optimization. Backtracking basically means trying
all possible options. It is used when you have multiple solution and you want
all those solutions.
Problems that follow backtracking strategy:
• N-Queen’s Problems
• Graph Colouring
• Hamiltonian Cycle
5. Branch and Bound:
• It is similar to the backtracking since it also uses the state space tree. It is used
for solving the optimization problems and minimization problems.
• A branch and bound algorithm is an optimization technique to get an optimal
solution to the problem. It looks for the best solution for a given problem in the
entire space of the solution. The bounds in the function to be optimized are
merged with the value of the latest best solution.
Problem that follow branch and bound strategy:
• Travelling Salesman Problem
After completion the course, Students will
be able to:
• Determine the time and space complexity of simple algorithms.
• Use notations to give upper, lower, and tight bounds on time and space
complexity of algorithms.
• Practice the main algorithm design strategies of Brute Force, Divide and
Conquer, Greedy Methods, Dynamic Programming, Backtracking, and Branch
and Bound and implement examples of each.
• Implement the most common sorting and searching algorithms and perform
their complexity analysis.
• Solve problems using the fundamental graph algorithms.
• Evaluate, select and implement algorithms in programming context.
Reference Books:
• Coremen Thomas, Leiserson CE, Rivest RL; Introduction to Algorithms; PHI.
• Horowitz & Sahani; Analysis & Design of Algorithm
• Dasgupta; algorithms; TMH
• Ullmann; Analysis & Design of Algorithm
• Michael T Goodrich, Robarto Tamassia, Algorithm Design, Wiely India
Analysis and Design of Algorithms
Analysis and Design of Algorithms

More Related Content

What's hot

daa-unit-3-greedy method
daa-unit-3-greedy methoddaa-unit-3-greedy method
daa-unit-3-greedy method
hodcsencet
 
DESIGN AND ANALYSIS OF ALGORITHMS
DESIGN AND ANALYSIS OF ALGORITHMSDESIGN AND ANALYSIS OF ALGORITHMS
DESIGN AND ANALYSIS OF ALGORITHMS
Gayathri Gaayu
 
Dinive conquer algorithm
Dinive conquer algorithmDinive conquer algorithm
Dinive conquer algorithm
Mohd Arif
 

What's hot (20)

Divide and conquer
Divide and conquerDivide and conquer
Divide and conquer
 
daa-unit-3-greedy method
daa-unit-3-greedy methoddaa-unit-3-greedy method
daa-unit-3-greedy method
 
Daa
DaaDaa
Daa
 
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
 
Data Structure and Algorithm - Divide and Conquer
Data Structure and Algorithm - Divide and ConquerData Structure and Algorithm - Divide and Conquer
Data Structure and Algorithm - Divide and Conquer
 
Design and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptxDesign and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptx
 
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
 
Strassen's matrix multiplication
Strassen's matrix multiplicationStrassen's matrix multiplication
Strassen's matrix multiplication
 
DESIGN AND ANALYSIS OF ALGORITHMS
DESIGN AND ANALYSIS OF ALGORITHMSDESIGN AND ANALYSIS OF ALGORITHMS
DESIGN AND ANALYSIS OF ALGORITHMS
 
Dinive conquer algorithm
Dinive conquer algorithmDinive conquer algorithm
Dinive conquer algorithm
 
Hill climbing algorithm
Hill climbing algorithmHill climbing algorithm
Hill climbing algorithm
 
Divide and Conquer - Part 1
Divide and Conquer - Part 1Divide and Conquer - Part 1
Divide and Conquer - Part 1
 
Bruteforce algorithm
Bruteforce algorithmBruteforce algorithm
Bruteforce algorithm
 
Backtracking
Backtracking  Backtracking
Backtracking
 
finding Min and max element from given array using divide & conquer
finding Min and max element from given array using  divide & conquer finding Min and max element from given array using  divide & conquer
finding Min and max element from given array using divide & conquer
 
Dijkstra's algorithm presentation
Dijkstra's algorithm presentationDijkstra's algorithm presentation
Dijkstra's algorithm presentation
 
Greedy Algorihm
Greedy AlgorihmGreedy Algorihm
Greedy Algorihm
 
NP completeness
NP completenessNP completeness
NP completeness
 
P, NP, NP-Complete, and NP-Hard
P, NP, NP-Complete, and NP-HardP, NP, NP-Complete, and NP-Hard
P, NP, NP-Complete, and NP-Hard
 
Merge Sort
Merge SortMerge Sort
Merge Sort
 

Similar to Analysis and Design of Algorithms

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
 
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
 

Similar to Analysis and Design of Algorithms (20)

2. Introduction to Algorithm.pptx
2. Introduction to Algorithm.pptx2. Introduction to Algorithm.pptx
2. Introduction to Algorithm.pptx
 
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
 
CH-1.1 Introduction (1).pptx
CH-1.1 Introduction (1).pptxCH-1.1 Introduction (1).pptx
CH-1.1 Introduction (1).pptx
 
Unit 1, ADA.pptx
Unit 1, ADA.pptxUnit 1, ADA.pptx
Unit 1, ADA.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
 
Algorithm and C code related to data structure
Algorithm and C code related to data structureAlgorithm and C code related to data structure
Algorithm and C code related to data structure
 
Python algorithm
Python algorithmPython algorithm
Python algorithm
 
Algorithm.pptx
Algorithm.pptxAlgorithm.pptx
Algorithm.pptx
 
Algorithm.pptx
Algorithm.pptxAlgorithm.pptx
Algorithm.pptx
 
1_Introduction.pptx
1_Introduction.pptx1_Introduction.pptx
1_Introduction.pptx
 
Algorithms & Complexity Calculation
Algorithms & Complexity CalculationAlgorithms & Complexity Calculation
Algorithms & Complexity Calculation
 
Introduction to Algorithms Complexity Analysis
Introduction to Algorithms Complexity Analysis Introduction to Algorithms Complexity Analysis
Introduction to Algorithms Complexity Analysis
 
Algorithm Introduction
Algorithm IntroductionAlgorithm Introduction
Algorithm Introduction
 
CS8461 - Design and Analysis of Algorithms
CS8461 - Design and Analysis of AlgorithmsCS8461 - Design and Analysis of Algorithms
CS8461 - Design and Analysis of Algorithms
 
Lec1.ppt
Lec1.pptLec1.ppt
Lec1.ppt
 
Algorithm Analysis.pdf
Algorithm Analysis.pdfAlgorithm Analysis.pdf
Algorithm Analysis.pdf
 
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
 

More from Bulbul Agrawal

More from Bulbul Agrawal (6)

Software Metrics, Project Management and Estimation
Software Metrics, Project Management and EstimationSoftware Metrics, Project Management and Estimation
Software Metrics, Project Management and Estimation
 
Age Estimation And Gender Prediction Using Convolutional Neural Network.pptx
Age Estimation And Gender Prediction Using Convolutional Neural Network.pptxAge Estimation And Gender Prediction Using Convolutional Neural Network.pptx
Age Estimation And Gender Prediction Using Convolutional Neural Network.pptx
 
Techniques for creating an effective resume
Techniques for creating an effective resumeTechniques for creating an effective resume
Techniques for creating an effective resume
 
Standard Statistical Feature analysis of Image Features for Facial Images usi...
Standard Statistical Feature analysis of Image Features for Facial Images usi...Standard Statistical Feature analysis of Image Features for Facial Images usi...
Standard Statistical Feature analysis of Image Features for Facial Images usi...
 
Image segmentation
Image segmentationImage segmentation
Image segmentation
 
Image enhancement techniques
Image enhancement techniquesImage enhancement techniques
Image enhancement techniques
 

Recently uploaded

Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
jaanualu31
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
Neometrix_Engineering_Pvt_Ltd
 

Recently uploaded (20)

FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdf
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdf
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptxOrlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
 
kiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadkiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal load
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdf
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLEGEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
 
Wadi Rum luxhotel lodge Analysis case study.pptx
Wadi Rum luxhotel lodge Analysis case study.pptxWadi Rum luxhotel lodge Analysis case study.pptx
Wadi Rum luxhotel lodge Analysis case study.pptx
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
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
 

Analysis and Design of Algorithms

  • 1. Introduction to Analysis & Design of Algorithm Submitted by: Prof. Bulbul Agrawal Assistant Professor Department of Computer Science & Engineering and Information Technology
  • 2. Content • Terminologies • Course Objective • Skeleton of the ADA • Introduction to ADA • Asymptotic Notations • Algorithm Design Techniques
  • 3. Terminologies: • Algorithm Design: Methods for designing efficient algorithms. • Algorithm Analysis: Analysis of resource usage of given algorithms. (Time & Space)
  • 4. Why do we study this subject? • Efficient algorithms lead to efficient programs. • Efficient programs sell better. • Efficient programs make better used of hardware. • Programmers who write efficient programs are preferred.
  • 5. Course Objective: • The data structure includes analyzing various algorithms along with time and space complexities. It also helps students to design new algorithms through mathematical analysis and programming.
  • 6. Skeleton of ADA: ADA Unit:1 Divide and Conquer Unit:2 Greedy Strategy Unit:3 Dynamic Programming Unit:4 Backtracking and Branch & Bound Unit:5 Graphs and Trees
  • 7. Introduction: • The set of rules that define how a particular problem can be solved in finite number of steps is known as algorithm. • An algorithm is a list of steps (Sequence of unambiguous instructions) for solving a problem that transforms the input into the output. Problem Algorithm Computer Input Output
  • 8. Designing of an algorithm: Understand the problem Decision making on: Capabilities of computational devices Algorithm Design Techniques Data Structures Specification of algorithms Analysis of algorithm Algorithm verification Code the algorithm
  • 9. Properties of an algorithm: • An algorithm takes zero or more inputs. • An algorithm results in one or more outputs. • All operations can be carried out in a finite amount of time. • An algorithm should be efficient and flexible. • It should use less memory space as much as possible. • An algorithm must terminate after a finite number of steps. • Each step in the algorithm must be easily understood. • An algorithm should be concise and compact to facilitate verification of their correctness.
  • 10. Two main tasks in the study of Algorithms: • Algorithm Design • Analysis of Algorithms
  • 11. How to analyzed the algorithm? Algorithm efficiency can be measured by two aspects; Time Complexity: Given in terms of frequency count • Instructions take time. • How fast does the algorithm perform? • What affects its runtime? Space Complexity: Amount of memory required • Data structure take space. • What kind of data structure can be used? • How does choice of data structure affect the runtime?
  • 12. Asymptotic Notations:  Given two algorithms for a task, how we find out which one is better? 1. It might be possible that for some inputs, first algorithm performs better than the second. And for some inputs second performs better. 2. Or it might also be possible that for some inputs, first algorithm perform better on one machine and the second works better on other machine for some other inputs.  So Asymptotic Notation is the big idea that handles above issues in analysing algorithms. In Asymptotic Analysis, we evaluate the performance of an algorithm in terms of input size.  Using Asymptotic Analysis we can very well conclude the Best Case, Average Case, and Worst Case scenario of an algorithm.
  • 13. Asymptotic Notations: • Asymptotic Notations are used to represent the complexity of an algorithm. • Asymptotic Notations provides with a mechanism to calculate and represent time and space complexity for any algorithm. Order of Growth: • Order of growth in algorithm means how the time for computation increase when you increase the input size. It really matters when your input size is very large.
  • 14. Kind of Analysis: Usually the time required by an algorithm falls under three types:  Best Case: Minimum time required for algorithm execution  Average Case: Average time required for algorithm execution  Worst Case: Worst time required for algorithm execution Following are the commonly used asymptotic notations to calculate the running time complexity of an algorithm;  O-Notation (Big-Oh Notation)  Ω-Notation (Omega Notation)  Θ-Notation (Theta Notation)
  • 15. O-Notation (Big-Oh Notation): • Big-O notation represents the upper bound of the running time of an algorithm. Thus, it gives the worst-case complexity of an algorithm. • Given two functions f(n) & g(n) for input n, we say f(n) is in O(g(n) ) iff there exist positive constants c and n0 such that f(n)  c g(n) for all n  n0 • Basically, we want to find a function g(n) that is eventually always bigger than f(n). • g(n) is an asymptotic upper bound for f(n).
  • 16. Ω-Notation (Omega Notation): • Omega notation represents the lower bound of the running time of an algorithm. Thus, it provides the best case complexity of an algorithm. • Given two functions f(n) & g(n) for input n, we say f(n) is in Ω(g(n) ) iff there exist positive constants c and n0 such that f(n)  c g(n) for all n  n0 • Basically, we want to find a function g(n) that is eventually always smaller than f(n). • g(n) is an asymptotic lower bound for f(n).
  • 17. Θ-Notation (Theta Notation): • Since it represents the upper and the lower bound of the running time of an algorithm, it is used for analyzing the average-case complexity of an algorithm. • Given two functions f(n) & g(n) for input n, we say f(n) is in Θ(g(n) ) iff there exist positive constants C1 & C2 and n0 such that C1 g(n)  f(n)  C2 g(n) for all n  n0 • g(n) is an asymptotically tight bound for f(n).
  • 18. Algorithm Design Strategies: We can design an algorithm by choose the one of the following strategies: 1. Divide and Conquer 2. Greedy Algorithm 3. Dynamic programming 4. Backtracking 5. Branch and Bound
  • 19. 1. Divide & Conquer Strategy: The algorithm which follows divide and conquer technique involves 3 steps: 1. Divide the original problem into a set of sub problems. 2. Conquer (or solve) every sub-problem individually, recursive. 3. Combine the solutions of these sub problems to get the solution of original problem.  Problems that follow divide and conquer strategy: • Merge Sort • Binary Search • Strassen's Matrix Multiplication
  • 20. 2. Greedy Strategy: • Greedy technique is used to solve an optimization problem. (Repeatedly do what is best now) • An Optimization problem is one in which, we are given a set of input values, which are required to be either maximized or minimized (known as objective function) w.r.t. some constraints or conditions. • The greedy algorithm does not always guarantee the optimal solution but it generally produces solutions that are very close in value to the optimal.  Problems that follow greedy strategy: • Fractional Knapsack Problem • Minimum Spanning Tress • Single Source Shortest Path Algorithm • Job Sequencing With Deadline
  • 21. 3. Dynamic Programming: • Dynamic programming is a technique that breaks the problems into sub- problems, and saves the result for future purposes so that we do not need to compute the result again. • The subproblems are optimized to optimize the overall solution is known as optimal substructure property. Problems that follow dynamic strategy: • 0/1 Knapsack • Matrix Chain Multiplication • Multistage Graph
  • 22. 4. Backtracking: • Backtracking is an algorithmic technique for solving problems by trying to build a solution incrementally, one piece at a time, removing those solutions that fail to satisfy the constraints of the problem at any point • Backtracking is not used for optimization. Backtracking basically means trying all possible options. It is used when you have multiple solution and you want all those solutions. Problems that follow backtracking strategy: • N-Queen’s Problems • Graph Colouring • Hamiltonian Cycle
  • 23. 5. Branch and Bound: • It is similar to the backtracking since it also uses the state space tree. It is used for solving the optimization problems and minimization problems. • A branch and bound algorithm is an optimization technique to get an optimal solution to the problem. It looks for the best solution for a given problem in the entire space of the solution. The bounds in the function to be optimized are merged with the value of the latest best solution. Problem that follow branch and bound strategy: • Travelling Salesman Problem
  • 24. After completion the course, Students will be able to: • Determine the time and space complexity of simple algorithms. • Use notations to give upper, lower, and tight bounds on time and space complexity of algorithms. • Practice the main algorithm design strategies of Brute Force, Divide and Conquer, Greedy Methods, Dynamic Programming, Backtracking, and Branch and Bound and implement examples of each. • Implement the most common sorting and searching algorithms and perform their complexity analysis. • Solve problems using the fundamental graph algorithms. • Evaluate, select and implement algorithms in programming context.
  • 25. Reference Books: • Coremen Thomas, Leiserson CE, Rivest RL; Introduction to Algorithms; PHI. • Horowitz & Sahani; Analysis & Design of Algorithm • Dasgupta; algorithms; TMH • Ullmann; Analysis & Design of Algorithm • Michael T Goodrich, Robarto Tamassia, Algorithm Design, Wiely India