SlideShare a Scribd company logo
Algorithms
Presented by:-
Dr. Soni Chaurasia
Associate Professor
Table of contents
 Introduction
 Algorithm
 Analysis of algorithms
 Asymptotic Complexity
 Asymptotic Notation
 Conclusion
Introduction
• The methods of algorithm design form one of the
core practical technologies of computer science.
• The main aim of this lecture is to familiarize the
student with the framework used throughout the
course for the design and analysis of algorithms.
• The algorithms needed to solve computational
problems. The problem of sorting is used as a
running example.
• A pseudocode to show how we shall specify the
algorithms.
Algorithms
• The word algorithm comes from the name of a
Persian mathematician Abu Ja’far Mohammed ibn-
i Musa al Khowarizmi.
• In computer science, this word refers to a special
method useable by a computer for solution of a
problem.
• The statement of the problem specifies in general
terms the desired input/output relationship.
Algorithm
 The word Algorithm means ” A set of finite rules or
instructions to be followed in calculations or other
problem-solving operations ”
Or
” A procedure for solving a mathematical problem in a
finite number of steps that frequently involves recursive
operations”.
Characteristics of an
Algorithm
Need for algorithms
1. Algorithms are necessary for solving complex
problems efficiently and effectively.
2. They help to automate processes and make them
more reliable, faster, and easier to perform.
3. Algorithms also enable computers to perform tasks
that would be difficult or impossible for humans to do
manually.
4. They are used in various fields such as mathematics,
computer science, engineering, finance, and many
others to optimize processes, analyze data, make
predictions, and provide solutions to problems.
Types of Algorithms:
 1. Brute Force Algorithm:
 It is the simplest approach to a problem. A brute force
algorithm is the first approach that comes to finding
when we see a problem.
 2. Recursive Algorithm:
 A recursive algorithm is based on recursion. In this case,
a problem is broken into several sub-parts and called
the same function again and again.
Cont…
 3. Backtracking Algorithm:
 The backtracking algorithm builds the solution by searching
among all possible solutions. Using this algorithm, we keep
on building the solution following criteria. Whenever a
solution fails we trace back to the failure point build on the
next solution and continue this process till we find the
solution or all possible solutions are looked after.
 4. Searching Algorithm:
 Searching algorithms are the ones that are used for
searching elements or groups of elements from a particular
data structure. They can be of different types based on
their approach or the data structure in which the element
should be found.
Cont…
 5. Sorting Algorithm:
 Sorting is arranging a group of data in a particular
manner according to the requirement. The algorithms
which help in performing this function are called sorting
algorithms. Generally sorting algorithms are used to sort
groups of data in an increasing or decreasing manner.
 6. Hashing Algorithm:
 Hashing algorithms work similarly to the searching
algorithm. But they contain an index with a key ID. In
hashing, a key is assigned to specific data.
Cont…
 7. Divide and Conquer Algorithm:
 This algorithm breaks a problem into sub-problems,
solves a single sub-problem, and merges the solutions to
get the final solution. It consists of the following three
steps: Divide, Solve, and Combine
 8. Greedy Algorithm:
 In this type of algorithm, the solution is built part by
part. The solution for the next part is built based on the
immediate benefit of the next part. The one solution
that gives the most benefit will be chosen as the
solution for the next part.
Cont…
 9. Dynamic Programming Algorithm:
 This algorithm uses the concept of using the already
found solution to avoid repetitive calculation of the
same part of the problem. It divides the problem into
smaller overlapping subproblems and solves them.
 10. Randomized Algorithm:
 In the randomized algorithm, we use a random number
so it gives immediate benefit. The random number
helps in deciding the expected outcome.
Analysis of algorithms
Why study algorithms and performance?
• Algorithms help us to understand scalability.
• Algorithmic mathematics provides a language for talking
about program behavior.
• Evaluate the performance of the algorithm based on the
given model and metrics: running time, and order of
growth.
•Kinds of analyses: Worst-case, Average-case, and Best-
case.
Asymptotic Complexity
 Running time of an algorithm as a function of input size
n for large n.
 Expressed using only the highest-order term in the
expression for the exact running time.
 Describes behavior of function in the limit.
 Written using Asymptotic Notation.
Asymptotic Notation
 O, ,, o, 
 Defined for functions over the natural numbers.
 Ex: f(n) = (n2
).
 Describes how f(n) grows in comparison to n2
.
 Define a set of functions; in practice used to
compare two function sizes.
 The notations describe different rate-of-growth
relations between the defining function and the
defined set of functions.
O-notation
O(g(n)) = {f(n) :
 positive constants c and n0,
such that n  n0,
we have 0  f(n)  cg(n) }
For function g(n), we define O(g(n)),
big-O of n, as the set:
g(n) is an asymptotic upper bound for f(n).
Intuitively: Set of all functions
whose rate of growth is the same as
or lower than that of g(n).
f(n) = O(g(n)).
Examples
 Example: Find upper bound of running time of a linear
function f(n) = 6n + 3.
 To find upper bound of f(n), we have to find c and
n0 such that 0 ≤ f (n) ≤ c × g (n) for all n ≥ n0
 0 ≤ f (n) ≤ c × g (n)
 0 ≤ 6n + 3 ≤ c × g (n)
 0 ≤ 6n + 3 ≤ 6n + 3n, for all n ≥ 1 (There can be such
infinite possibilities)
 0 ≤ 6n + 3 ≤ 9n
 So, c = 9 and g (n) = n, n0 = 1
 -notation
g(n) is an asymptotic lower bound for f(n).
Intuitively: Set of all functions
whose rate of growth is the same
as or higher than that of g(n).
f(n) = (g(n)).
(g(n)) = {f(n) :
 positive constants c and n0,
such that n  n0,
we have 0  cg(n)  f(n)}
For function g(n), we define (g(n)),
big-Omega of n, as the set:
Examples
 Example: Find lower bound of running time of a linear function
f(n) = 6n + 3.
 To find lower bound of f(n), we have to find c and n0 such that 0
≤ c.g(n) ≤ f(n) for all n ≥ n0
 0 ≤ c × g(n) ≤ f(n)
 0 ≤ c × g(n) ≤ 6n + 3
 0 ≤ 6n ≤ 6n + 3 → true, for all n ≥ n0
 0 ≤ 5n ≤ 6n + 3 → true, for all n ≥ n0
 Above both inequalities are true and there exists such infinite
inequalities. So,
 f(n) = Ω (g(n)) = Ω (n) for c = 6, n0 = 1
 f(n) = Ω (g(n)) = Ω (n) for c = 5, n0 = 1
 and so on.
-notation
(g(n)) = {f(n) :
 positive constants c1, c2, and n0,
such that n  n0,
we have 0  c1g(n)  f(n) 
c2g(n)
}
For function g(n), we define (g(n)),
big-Theta of n, as the set:
g(n) is an asymptotically tight bound for f(n).
Intuitively: Set of all functions that
have the same rate of growth as g(n).
o-notation
f(n) becomes insignificant relative to g(n) as n
approaches infinity:
lim [f(n) / g(n)] = 0
n
g(n) is an upper bound for f(n) that is not
asymptotically tight.
o(g(n)) = {f(n):  c > 0,  n0 > 0 such that
 n  n0, we have 0  f(n) < cg(n)}.
For a given function g(n), the set little-o:
(g(n)) = {f(n):  c > 0,  n0 > 0 such that
 n  n0, we have 0  cg(n) < f(n)}.
 -notation
f(n) becomes arbitrarily large relative to g(n) as n
approaches infinity:
lim [f(n) / g(n)] = .
n
g(n) is a lower bound for f(n) that is not asymptotically
tight.
For a given function g(n), the set little-omega:
Conclusion
 To provide main notions of algorithm.
 To learn formal framework to draw basic elements.
 To study and analysis of algorithm along with
completeness.
 To learn framework for application-based design.
analysis of algorithms and asymptotic complexity

More Related Content

Similar to analysis of algorithms and asymptotic complexity (20)

PPTX
Data structures notes for college students btech.pptx
KarthikVijay59
 
PDF
Unit 1_final DESIGN AND ANALYSIS OF ALGORITHM.pdf
saiscount01
 
PPTX
Algorithm for the DAA agscsnak javausmagagah
RaviPandey598038
 
PPTX
Algorithms DM
Rokonuzzaman Rony
 
PPTX
DAA-Unit1.pptx
NishaS88
 
PDF
Data Structures and Algorithms - Lec 02.pdf
RameshaFernando2
 
PPT
AsymptoticAnalysis-goal of analysis of algorithms
DesiSmartCooking
 
PPT
Asymptotic Notation and Complexity
Rajandeep Gill
 
PPT
AsymptoticAnalysis.ppt
SiddheshUpadhyay3
 
PDF
1ST_UNIT_DAdefewfrewfgrwefrAdfdgfdsgevedr (2).pdf
ravisikka1
 
PPT
Algorithms
yashodhaHR2
 
PPT
Design and analysis of algorithm in Computer Science
secularistpartyofind
 
PPTX
DS Unit-1.pptx very easy to understand..
KarthikeyaLanka1
 
PPT
Data Structures and Algorithm Analysis
Mary Margarat
 
PPT
Aad introduction
Mr SMAK
 
PPTX
Design and analysis of algorithms unit1.pptx
ShivaniSharma335055
 
PDF
1_Asymptdjfjfjfnfncnotic_Notation_pptx.pdf
NagendraK18
 
PPTX
Asymptotics 140510003721-phpapp02
mansab MIRZA
 
PPT
Algorithm analysis basics - Seven Functions/Big-Oh/Omega/Theta
Priyanka Rana
 
PDF
Cs6402 daa-2 marks set 1
Vai Jayanthi
 
Data structures notes for college students btech.pptx
KarthikVijay59
 
Unit 1_final DESIGN AND ANALYSIS OF ALGORITHM.pdf
saiscount01
 
Algorithm for the DAA agscsnak javausmagagah
RaviPandey598038
 
Algorithms DM
Rokonuzzaman Rony
 
DAA-Unit1.pptx
NishaS88
 
Data Structures and Algorithms - Lec 02.pdf
RameshaFernando2
 
AsymptoticAnalysis-goal of analysis of algorithms
DesiSmartCooking
 
Asymptotic Notation and Complexity
Rajandeep Gill
 
AsymptoticAnalysis.ppt
SiddheshUpadhyay3
 
1ST_UNIT_DAdefewfrewfgrwefrAdfdgfdsgevedr (2).pdf
ravisikka1
 
Algorithms
yashodhaHR2
 
Design and analysis of algorithm in Computer Science
secularistpartyofind
 
DS Unit-1.pptx very easy to understand..
KarthikeyaLanka1
 
Data Structures and Algorithm Analysis
Mary Margarat
 
Aad introduction
Mr SMAK
 
Design and analysis of algorithms unit1.pptx
ShivaniSharma335055
 
1_Asymptdjfjfjfnfncnotic_Notation_pptx.pdf
NagendraK18
 
Asymptotics 140510003721-phpapp02
mansab MIRZA
 
Algorithm analysis basics - Seven Functions/Big-Oh/Omega/Theta
Priyanka Rana
 
Cs6402 daa-2 marks set 1
Vai Jayanthi
 

Recently uploaded (20)

PPTX
L300 Technical Slide Library_Feb 2025 microsoft purview
macarenabenitez6
 
PPTX
UNIT 1 - INTRODUCTION TO AI and AI tools and basic concept
gokuld13012005
 
PDF
methodology-driven-mbse-murphy-july-hsv-huntsville6680038572db67488e78ff00003...
henriqueltorres1
 
PPTX
Explore USA’s Best Structural And Non Structural Steel Detailing
Silicon Engineering Consultants LLC
 
PPTX
Distribution reservoir and service storage pptx
dhanashree78
 
PPTX
Engineering Quiz ShowEngineering Quiz Show
CalvinLabial
 
PDF
Clustering Algorithms - Kmeans,Min ALgorithm
Sharmila Chidaravalli
 
PDF
Artificial intelligence,WHAT IS AI ALL ABOUT AI....pdf
Himani271945
 
PPT
Footbinding.pptmnmkjkjkknmnnjkkkkkkkkkkkkkk
mamadoundiaye42742
 
PPTX
Fundamentals of Quantitative Design and Analysis.pptx
aliali240367
 
PDF
LLC CM NCP1399 SIMPLIS MODEL MANUAL.PDF
ssuser1be9ce
 
PDF
Module - 4 Machine Learning -22ISE62.pdf
Dr. Shivashankar
 
PPTX
darshai cross section and river section analysis
muk7971
 
PPSX
OOPS Concepts in Python and Exception Handling
Dr. A. B. Shinde
 
PPTX
Alan Turing - life and importance for all of us now
Pedro Concejero
 
PDF
William Stallings - Foundations of Modern Networking_ SDN, NFV, QoE, IoT, and...
lavanya896395
 
PDF
Información de microsoft purview herramienta de microsoft
macarenabenitez6
 
PDF
Submit Your Papers-International Journal on Cybernetics & Informatics ( IJCI)
IJCI JOURNAL
 
PDF
PROGRAMMING REQUESTS/RESPONSES WITH GREATFREE IN THE CLOUD ENVIRONMENT
samueljackson3773
 
PDF
A Brief Introduction About Robert Paul Hardee
Robert Paul Hardee
 
L300 Technical Slide Library_Feb 2025 microsoft purview
macarenabenitez6
 
UNIT 1 - INTRODUCTION TO AI and AI tools and basic concept
gokuld13012005
 
methodology-driven-mbse-murphy-july-hsv-huntsville6680038572db67488e78ff00003...
henriqueltorres1
 
Explore USA’s Best Structural And Non Structural Steel Detailing
Silicon Engineering Consultants LLC
 
Distribution reservoir and service storage pptx
dhanashree78
 
Engineering Quiz ShowEngineering Quiz Show
CalvinLabial
 
Clustering Algorithms - Kmeans,Min ALgorithm
Sharmila Chidaravalli
 
Artificial intelligence,WHAT IS AI ALL ABOUT AI....pdf
Himani271945
 
Footbinding.pptmnmkjkjkknmnnjkkkkkkkkkkkkkk
mamadoundiaye42742
 
Fundamentals of Quantitative Design and Analysis.pptx
aliali240367
 
LLC CM NCP1399 SIMPLIS MODEL MANUAL.PDF
ssuser1be9ce
 
Module - 4 Machine Learning -22ISE62.pdf
Dr. Shivashankar
 
darshai cross section and river section analysis
muk7971
 
OOPS Concepts in Python and Exception Handling
Dr. A. B. Shinde
 
Alan Turing - life and importance for all of us now
Pedro Concejero
 
William Stallings - Foundations of Modern Networking_ SDN, NFV, QoE, IoT, and...
lavanya896395
 
Información de microsoft purview herramienta de microsoft
macarenabenitez6
 
Submit Your Papers-International Journal on Cybernetics & Informatics ( IJCI)
IJCI JOURNAL
 
PROGRAMMING REQUESTS/RESPONSES WITH GREATFREE IN THE CLOUD ENVIRONMENT
samueljackson3773
 
A Brief Introduction About Robert Paul Hardee
Robert Paul Hardee
 
Ad

analysis of algorithms and asymptotic complexity

  • 1. Algorithms Presented by:- Dr. Soni Chaurasia Associate Professor
  • 2. Table of contents  Introduction  Algorithm  Analysis of algorithms  Asymptotic Complexity  Asymptotic Notation  Conclusion
  • 3. Introduction • The methods of algorithm design form one of the core practical technologies of computer science. • The main aim of this lecture is to familiarize the student with the framework used throughout the course for the design and analysis of algorithms. • The algorithms needed to solve computational problems. The problem of sorting is used as a running example. • A pseudocode to show how we shall specify the algorithms.
  • 4. Algorithms • The word algorithm comes from the name of a Persian mathematician Abu Ja’far Mohammed ibn- i Musa al Khowarizmi. • In computer science, this word refers to a special method useable by a computer for solution of a problem. • The statement of the problem specifies in general terms the desired input/output relationship.
  • 5. Algorithm  The word Algorithm means ” A set of finite rules or instructions to be followed in calculations or other problem-solving operations ” Or ” A procedure for solving a mathematical problem in a finite number of steps that frequently involves recursive operations”.
  • 7. Need for algorithms 1. Algorithms are necessary for solving complex problems efficiently and effectively. 2. They help to automate processes and make them more reliable, faster, and easier to perform. 3. Algorithms also enable computers to perform tasks that would be difficult or impossible for humans to do manually. 4. They are used in various fields such as mathematics, computer science, engineering, finance, and many others to optimize processes, analyze data, make predictions, and provide solutions to problems.
  • 8. Types of Algorithms:  1. Brute Force Algorithm:  It is the simplest approach to a problem. A brute force algorithm is the first approach that comes to finding when we see a problem.  2. Recursive Algorithm:  A recursive algorithm is based on recursion. In this case, a problem is broken into several sub-parts and called the same function again and again.
  • 9. Cont…  3. Backtracking Algorithm:  The backtracking algorithm builds the solution by searching among all possible solutions. Using this algorithm, we keep on building the solution following criteria. Whenever a solution fails we trace back to the failure point build on the next solution and continue this process till we find the solution or all possible solutions are looked after.  4. Searching Algorithm:  Searching algorithms are the ones that are used for searching elements or groups of elements from a particular data structure. They can be of different types based on their approach or the data structure in which the element should be found.
  • 10. Cont…  5. Sorting Algorithm:  Sorting is arranging a group of data in a particular manner according to the requirement. The algorithms which help in performing this function are called sorting algorithms. Generally sorting algorithms are used to sort groups of data in an increasing or decreasing manner.  6. Hashing Algorithm:  Hashing algorithms work similarly to the searching algorithm. But they contain an index with a key ID. In hashing, a key is assigned to specific data.
  • 11. Cont…  7. Divide and Conquer Algorithm:  This algorithm breaks a problem into sub-problems, solves a single sub-problem, and merges the solutions to get the final solution. It consists of the following three steps: Divide, Solve, and Combine  8. Greedy Algorithm:  In this type of algorithm, the solution is built part by part. The solution for the next part is built based on the immediate benefit of the next part. The one solution that gives the most benefit will be chosen as the solution for the next part.
  • 12. Cont…  9. Dynamic Programming Algorithm:  This algorithm uses the concept of using the already found solution to avoid repetitive calculation of the same part of the problem. It divides the problem into smaller overlapping subproblems and solves them.  10. Randomized Algorithm:  In the randomized algorithm, we use a random number so it gives immediate benefit. The random number helps in deciding the expected outcome.
  • 13. Analysis of algorithms Why study algorithms and performance? • Algorithms help us to understand scalability. • Algorithmic mathematics provides a language for talking about program behavior. • Evaluate the performance of the algorithm based on the given model and metrics: running time, and order of growth. •Kinds of analyses: Worst-case, Average-case, and Best- case.
  • 14. Asymptotic Complexity  Running time of an algorithm as a function of input size n for large n.  Expressed using only the highest-order term in the expression for the exact running time.  Describes behavior of function in the limit.  Written using Asymptotic Notation.
  • 15. Asymptotic Notation  O, ,, o,   Defined for functions over the natural numbers.  Ex: f(n) = (n2 ).  Describes how f(n) grows in comparison to n2 .  Define a set of functions; in practice used to compare two function sizes.  The notations describe different rate-of-growth relations between the defining function and the defined set of functions.
  • 16. O-notation O(g(n)) = {f(n) :  positive constants c and n0, such that n  n0, we have 0  f(n)  cg(n) } For function g(n), we define O(g(n)), big-O of n, as the set: g(n) is an asymptotic upper bound for f(n). Intuitively: Set of all functions whose rate of growth is the same as or lower than that of g(n). f(n) = O(g(n)).
  • 17. Examples  Example: Find upper bound of running time of a linear function f(n) = 6n + 3.  To find upper bound of f(n), we have to find c and n0 such that 0 ≤ f (n) ≤ c × g (n) for all n ≥ n0  0 ≤ f (n) ≤ c × g (n)  0 ≤ 6n + 3 ≤ c × g (n)  0 ≤ 6n + 3 ≤ 6n + 3n, for all n ≥ 1 (There can be such infinite possibilities)  0 ≤ 6n + 3 ≤ 9n  So, c = 9 and g (n) = n, n0 = 1
  • 18.  -notation g(n) is an asymptotic lower bound for f(n). Intuitively: Set of all functions whose rate of growth is the same as or higher than that of g(n). f(n) = (g(n)). (g(n)) = {f(n) :  positive constants c and n0, such that n  n0, we have 0  cg(n)  f(n)} For function g(n), we define (g(n)), big-Omega of n, as the set:
  • 19. Examples  Example: Find lower bound of running time of a linear function f(n) = 6n + 3.  To find lower bound of f(n), we have to find c and n0 such that 0 ≤ c.g(n) ≤ f(n) for all n ≥ n0  0 ≤ c × g(n) ≤ f(n)  0 ≤ c × g(n) ≤ 6n + 3  0 ≤ 6n ≤ 6n + 3 → true, for all n ≥ n0  0 ≤ 5n ≤ 6n + 3 → true, for all n ≥ n0  Above both inequalities are true and there exists such infinite inequalities. So,  f(n) = Ω (g(n)) = Ω (n) for c = 6, n0 = 1  f(n) = Ω (g(n)) = Ω (n) for c = 5, n0 = 1  and so on.
  • 20. -notation (g(n)) = {f(n) :  positive constants c1, c2, and n0, such that n  n0, we have 0  c1g(n)  f(n)  c2g(n) } For function g(n), we define (g(n)), big-Theta of n, as the set: g(n) is an asymptotically tight bound for f(n). Intuitively: Set of all functions that have the same rate of growth as g(n).
  • 21. o-notation f(n) becomes insignificant relative to g(n) as n approaches infinity: lim [f(n) / g(n)] = 0 n g(n) is an upper bound for f(n) that is not asymptotically tight. o(g(n)) = {f(n):  c > 0,  n0 > 0 such that  n  n0, we have 0  f(n) < cg(n)}. For a given function g(n), the set little-o:
  • 22. (g(n)) = {f(n):  c > 0,  n0 > 0 such that  n  n0, we have 0  cg(n) < f(n)}.  -notation f(n) becomes arbitrarily large relative to g(n) as n approaches infinity: lim [f(n) / g(n)] = . n g(n) is a lower bound for f(n) that is not asymptotically tight. For a given function g(n), the set little-omega:
  • 23. Conclusion  To provide main notions of algorithm.  To learn formal framework to draw basic elements.  To study and analysis of algorithm along with completeness.  To learn framework for application-based design.