Machine Learning All topics Covers In This Single Slides
1. Introduction History
The Word: Algorithm
Abu Abdallah Muhammad ibn
Musa al-Khwarizmi
Earlier transliterated as
Algoritmi or Algaurizin
A Persian mathematician,
astronomer and geographer
Born: 780 AD, Khwarezm
Died: 850 AD, Baghdad, Iraq
Nationality: Iranian
Books: The Compendious Book
on Calculation by Completion
and Balancing
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 1 / 22
2. Introduction History
Algorithm by Euclid
Euclid created this algorithm
This algorithm calculates the
greatest common divisor, a
divide the number a by b, the
remainder is r
replace a by b
replace b by r
continue until a can’t be more
divided
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 2 / 22
3. Introduction Algorithm Design Paradigms
Algorithm Design Paradigms
Brute Force
Greedy Algorithms
Divide and Conquer
Decrease and Conquer
Transform and Conquer
Dynamic Programming
Backtracking
Genetic Algorithms
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 3 / 22
4. Introduction Algorithm Design Paradigms
Brute Force
Based on the problem’s statement and definitions of the concepts
involved. Examples:
Sequential search
Exhaustive search: TSP, knapsack
Simple sorts: selection sort, bubble sort
Computing n!
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 4 / 22
5. Introduction Algorithm Design Paradigms
Greedy Algorithms
Take what you can get now strategy
Work in phases
⇒ In each phase the currently best decision is made
Examples:
Dijkstra’s algorithm–shortest path is weighted graphs
Prim’s algorithm, Kruskal’s algorithm–minimal spanning tree in
weighted graphs
Coin exchange problem
Huffman Trees
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 5 / 22
6. Introduction Algorithm Design Paradigms
Divide and Conquer
In general, problems that can be defined recursively
Reduce the problem to smaller problems (by a factor of at least
2) solved recursively and then combine the solutions
Examples:
Binary Search
Mergesort
Quick sort
Tree traversal
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 6 / 22
7. Introduction Algorithm Design Paradigms
Decrease and Conquer
Reduce the problem to smaller problems solved recursively and
then combine the solutions
Examples:
Insertion sort
Topological sorting
Binary Tree traversals: inorder, preorder and postorder (recursion)
Computing the length of the longest path in a binary tree (recursion)
Computing Fibonacci numbers (recursion)
Reversing a queue (recursion)
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 7 / 22
8. Introduction Algorithm Design Paradigms
Transform and Conquer
The problem is modified to be more amenable to solution. In the
second stage the problem is solved.
Problem Simplification. For example, presorting. Finding the two
closest numbers in an array of numbers.
Brute force solution: ⃝(n2)
Transform and conquer with presorting:⃝(nlogn)
Change in the representation. Example: AVL trees guarantee
⃝(nlogn) search time.
Problem reduction. Example: least common multiple
lcm(m, n) =
m ∗ n
gcd(m, n)
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 8 / 22
9. Introduction Algorithm Design Paradigms
Dynamic Programming
Bottom-Up Technique in which the smallest sub-instances are
explicitly solved first and the results of these used to construct
solutions to progressively larger sub-instances.
Example:Fibonacci numbers computed by iteration.
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 9 / 22
10. Introduction Algorithm Design Paradigms
Backtracking
Generate-and-Test methods based on exhaustive search in mul-
tiple choice problems.Typically used with depth-first state space
search problems.
Example: puzzles
State Space Search
initial state
goal state(s)
a set of intermediate states
a set of operators that transform one state into another. Each
operator has preconditions and postconditions.
a cost function – evaluates the cost of the operations (optional)
a utility function – evaluates how close is a given state to the goal
state (optional)
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 10 / 22
11. Introduction Algorithm Design Paradigms
Genetic Algorithms
Search for good solutions among possible solutions
The best possible solution may be missed
A solution is coded by a string, also called chromosome. The words
string and chromosome are used interchangeably
A string’s fitness is a measure of how good a solution it codes.
Fitness is calculated by a fitness function
Selection: The procedure to choose parents
Crossover is the procedure by which two chromosomes mate to create
a new offspring chromosome
Mutation: with a certain probability flip a bit in the offspring
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 11 / 22
12. Introduction Concept of Algorithmic Efficiency
Algorithmic Efficiency
Analogous to Engg Productivity
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 12 / 22
13. Introduction Concept of Algorithmic Efficiency
Algorithmic Efficiency
Analogous to Engg Productivity
Properties of an algorithm which relate to the amount of resources
used by the algorithm
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 12 / 22
14. Introduction Concept of Algorithmic Efficiency
Algorithmic Efficiency
Analogous to Engg Productivity
Properties of an algorithm which relate to the amount of resources
used by the algorithm
Resources–Time and Space(memory)
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 12 / 22
15. Introduction Concept of Algorithmic Efficiency
Algorithmic Efficiency
Analogous to Engg Productivity
Properties of an algorithm which relate to the amount of resources
used by the algorithm
Resources–Time and Space(memory)
Measurement of resource usage :
– Expressed as a function of the size of the input n
– Time: how long does the algorithm take to complete
– Space: how much working memory (typically RAM) is needed by
the algorithm for its code and data
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 12 / 22
16. Introduction Concept of Algorithmic Efficiency
Algorithmic Efficiency
Analogous to Engg Productivity
Properties of an algorithm which relate to the amount of resources
used by the algorithm
Resources–Time and Space(memory)
Measurement of resource usage :
– Expressed as a function of the size of the input n
– Time: how long does the algorithm take to complete
– Space: how much working memory (typically RAM) is needed by
the algorithm for its code and data
Some other measurements :
– Direct/Indirect power consumption
– Transmission size
– External space
– Response time
– Total cost of ownership
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 12 / 22
17. Introduction Concept of Algorithmic Efficiency
Run Time Analysis of Algorithms
Is accurate measurement of run time possible?
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 13 / 22
18. Introduction Concept of Algorithmic Efficiency
Run Time Analysis of Algorithms
Is accurate measurement of run time possible?
Suppose, you are asked to design and analyze an algorithm. What would
you do?
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 13 / 22
19. Introduction Concept of Algorithmic Efficiency
Run Time Analysis of Algorithms
Is accurate measurement of run time possible?
Suppose, you are asked to design and analyze an algorithm. What would
you do?
1 Design the algorithm
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 13 / 22
20. Introduction Concept of Algorithmic Efficiency
Run Time Analysis of Algorithms
Is accurate measurement of run time possible?
Suppose, you are asked to design and analyze an algorithm. What would
you do?
1 Design the algorithm
2 Analyze time taken on RAM model
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 13 / 22
21. Introduction Concept of Algorithmic Efficiency
Run Time Analysis of Algorithms
Is accurate measurement of run time possible?
Suppose, you are asked to design and analyze an algorithm. What would
you do?
1 Design the algorithm
2 Analyze time taken on RAM model
3 Details of analysis is not applicable to other computer
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 13 / 22
22. Introduction Concept of Algorithmic Efficiency
Run Time Analysis of Algorithms
Is accurate measurement of run time possible?
Suppose, you are asked to design and analyze an algorithm. What would
you do?
1 Design the algorithm
2 Analyze time taken on RAM model
3 Details of analysis is not applicable to other computer
Suppose, RAM Time is 100n3 + 15n2 + 20
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 13 / 22
23. Introduction Concept of Algorithmic Efficiency
Run Time Analysis of Algorithms
Is accurate measurement of run time possible?
Suppose, you are asked to design and analyze an algorithm. What would
you do?
1 Design the algorithm
2 Analyze time taken on RAM model
3 Details of analysis is not applicable to other computer
Suppose, RAM Time is 100n3 + 15n2 + 20
For other computer, you would say time taken is Cubic.
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 13 / 22
24. Introduction Concept of Algorithmic Efficiency
Run Time Analysis of Algorithms
Is accurate measurement of run time possible?
Suppose, you are asked to design and analyze an algorithm. What would
you do?
1 Design the algorithm
2 Analyze time taken on RAM model
3 Details of analysis is not applicable to other computer
Suppose, RAM Time is 100n3 + 15n2 + 20
For other computer, you would say time taken is Cubic.
However, you would say cubic even for 5n3 + 20n + 39.
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 13 / 22
25. Introduction Concept of Algorithmic Efficiency
Run Time Analysis of Algorithms
Is accurate measurement of run time possible?
Suppose, you are asked to design and analyze an algorithm. What would
you do?
1 Design the algorithm
2 Analyze time taken on RAM model
3 Details of analysis is not applicable to other computer
Suppose, RAM Time is 100n3 + 15n2 + 20
For other computer, you would say time taken is Cubic.
However, you would say cubic even for 5n3 + 20n + 39.
You are saying approximate time taken by an algorithm in other
computer.
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 13 / 22
27. Introduction Asymptotic Notation
Asymptotic–the Word
What is an asymptote ?
– In analytic geometry, an asymptote of a curve
is a line such that the distance between the
curve and the line approaches zero as they tend
to infinity
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 14 / 22
28. Introduction Asymptotic Notation
Asymptotic–the Word
What is an asymptote ?
– In analytic geometry, an asymptote of a curve
is a line such that the distance between the
curve and the line approaches zero as they tend
to infinity
– a straight line that is closely approached by a
plane curve so that the perpendicular distance
between them decreases to zero as the distance
from the origin increases to infinity
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 14 / 22
29. Introduction Asymptotic Notation
Asymptotic–the Word
What is an asymptote ?
– In analytic geometry, an asymptote of a curve
is a line such that the distance between the
curve and the line approaches zero as they tend
to infinity
– a straight line that is closely approached by a
plane curve so that the perpendicular distance
between them decreases to zero as the distance
from the origin increases to infinity
– straight line continually approaching but never
meeting a curve
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 14 / 22
30. Introduction Asymptotic Notation
Asymptotic–the Word
What is an asymptote ?
– In analytic geometry, an asymptote of a curve
is a line such that the distance between the
curve and the line approaches zero as they tend
to infinity
– a straight line that is closely approached by a
plane curve so that the perpendicular distance
between them decreases to zero as the distance
from the origin increases to infinity
– straight line continually approaching but never
meeting a curve
– History: Comes from Greek word asumptotos,
which means not falling together
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 14 / 22
32. Introduction Asymptotic Notation
Asymptotic–the Word
So, what is asymptotic?
relating to or of the nature of an asymptote;
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 15 / 22
33. Introduction Asymptotic Notation
Asymptotic–the Word
So, what is asymptotic?
relating to or of the nature of an asymptote;
For example, an asymptotic function
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 15 / 22
34. Introduction Asymptotic Notation
Asymptotic–the Word
So, what is asymptotic?
relating to or of the nature of an asymptote;
For example, an asymptotic function
Asymptotic word is related to function
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 15 / 22
35. Introduction Asymptotic Notation
Classes of Function
What is Asymptotic Notation?
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 16 / 22
36. Introduction Asymptotic Notation
Classes of Function
What is Asymptotic Notation?
Asymptotic Notation Formal way or notation to speak about functions
and classify them.
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 16 / 22
37. Introduction Asymptotic Notation
Classes of Function
What is Asymptotic Notation?
Asymptotic Notation Formal way or notation to speak about functions
and classify them.
Asymptotic Analysis Classifying functions
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 16 / 22
38. Introduction Asymptotic Notation
Classes of Function
What is Asymptotic Notation?
Asymptotic Notation Formal way or notation to speak about functions
and classify them.
Asymptotic Analysis Classifying functions
Two features:
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 16 / 22
39. Introduction Asymptotic Notation
Classes of Function
What is Asymptotic Notation?
Asymptotic Notation Formal way or notation to speak about functions
and classify them.
Asymptotic Analysis Classifying functions
Two features:
1 Functions 100n3 + 15n2 + 20 and 5n3 + 20n + 39 should go to same
class. Here, ignore constant multipliers.
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 16 / 22
40. Introduction Asymptotic Notation
Classes of Function
What is Asymptotic Notation?
Asymptotic Notation Formal way or notation to speak about functions
and classify them.
Asymptotic Analysis Classifying functions
Two features:
1 Functions 100n3 + 15n2 + 20 and 5n3 + 20n + 39 should go to same
class. Here, ignore constant multipliers.
2 Give more importance to behavior as n → ∞.
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 16 / 22
41. Introduction Asymptotic Notation
Classes of Function
What is Asymptotic Notation?
Asymptotic Notation Formal way or notation to speak about functions
and classify them.
Asymptotic Analysis Classifying functions
Two features:
1 Functions 100n3 + 15n2 + 20 and 5n3 + 20n + 39 should go to same
class. Here, ignore constant multipliers.
2 Give more importance to behavior as n → ∞.
Θ, Ω and ⃝ notations: Definitions and examples to follow.
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 16 / 22
43. Introduction Asymptotic Notation
Θ Notation
Assume, two functions f and g, so that
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 17 / 22
44. Introduction Asymptotic Notation
Θ Notation
Assume, two functions f and g, so that
both are non-negative, and
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 17 / 22
45. Introduction Asymptotic Notation
Θ Notation
Assume, two functions f and g, so that
both are non-negative, and
both has non-negative arguments
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 17 / 22
46. Introduction Asymptotic Notation
Θ Notation
Assume, two functions f and g, so that
both are non-negative, and
both has non-negative arguments
Why non-negative ?
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 17 / 22
47. Introduction Asymptotic Notation
Θ Notation
Assume, two functions f and g, so that
both are non-negative, and
both has non-negative arguments
Why non-negative ?
Because, time and input are non-negative
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 17 / 22
48. Introduction Asymptotic Notation
Θ Notation
Assume, two functions f and g, so that
both are non-negative, and
both has non-negative arguments
Why non-negative ?
Because, time and input are non-negative
Θ(g) :
{f |f is a non-negative function s.t. ∃
constants c1, c2 and n0
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 17 / 22
49. Introduction Asymptotic Notation
Θ Notation
Assume, two functions f and g, so that
both are non-negative, and
both has non-negative arguments
Why non-negative ?
Because, time and input are non-negative
Θ(g) :
{f |f is a non-negative function s.t. ∃
constants c1, c2 and n0 s.t.
c1g(n) ≤ f (n) ≤ c2g(n)}
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 17 / 22
50. Introduction Asymptotic Notation
Θ Notation
Assume, two functions f and g, so that
both are non-negative, and
both has non-negative arguments
Why non-negative ?
Because, time and input are non-negative
Θ(g) :
{f |f is a non-negative function s.t. ∃
constants c1, c2 and n0 s.t.
c1g(n) ≤ f (n) ≤ c2g(n)} for n ≥ n0
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 17 / 22
51. Introduction Asymptotic Notation
Θ Notation
Assume, two functions f and g, so that
both are non-negative, and
both has non-negative arguments
Why non-negative ?
Because, time and input are non-negative
Θ(g) :
{f |f is a non-negative function s.t. ∃
constants c1, c2 and n0 s.t.
c1g(n) ≤ f (n) ≤ c2g(n)} for n ≥ n0
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 17 / 22
53. Introduction Asymptotic Notation
Ω Notation
Assume, two functions f and g, so that
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 18 / 22
54. Introduction Asymptotic Notation
Ω Notation
Assume, two functions f and g, so that
both are non-negative, and
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 18 / 22
55. Introduction Asymptotic Notation
Ω Notation
Assume, two functions f and g, so that
both are non-negative, and
both has non-negative arguments
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 18 / 22
56. Introduction Asymptotic Notation
Ω Notation
Assume, two functions f and g, so that
both are non-negative, and
both has non-negative arguments
Ω(g) :
{f |f is a non-negative function s.t. ∃
constants c and n0
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 18 / 22
57. Introduction Asymptotic Notation
Ω Notation
Assume, two functions f and g, so that
both are non-negative, and
both has non-negative arguments
Ω(g) :
{f |f is a non-negative function s.t. ∃
constants c and n0 s.t. 0 ≤ cg(n) ≤ f (n)}
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 18 / 22
58. Introduction Asymptotic Notation
Ω Notation
Assume, two functions f and g, so that
both are non-negative, and
both has non-negative arguments
Ω(g) :
{f |f is a non-negative function s.t. ∃
constants c and n0 s.t. 0 ≤ cg(n) ≤ f (n)}
for n ≥ n0
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 18 / 22
59. Introduction Asymptotic Notation
Ω Notation
Assume, two functions f and g, so that
both are non-negative, and
both has non-negative arguments
Ω(g) :
{f |f is a non-negative function s.t. ∃
constants c and n0 s.t. 0 ≤ cg(n) ≤ f (n)}
for n ≥ n0
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 18 / 22
60. Introduction Asymptotic Notation
Ω Notation
Assume, two functions f and g, so that
both are non-negative, and
both has non-negative arguments
Ω(g) :
{f |f is a non-negative function s.t. ∃
constants c and n0 s.t. 0 ≤ cg(n) ≤ f (n)}
for n ≥ n0
Asymptotic lower bound
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 18 / 22
61. Introduction Asymptotic Notation
Ω Notation
Assume, two functions f and g, so that
both are non-negative, and
both has non-negative arguments
Ω(g) :
{f |f is a non-negative function s.t. ∃
constants c and n0 s.t. 0 ≤ cg(n) ≤ f (n)}
for n ≥ n0
Asymptotic lower bound
Used to say an Algorithm shall take at least xyz time
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 18 / 22
62. Introduction Asymptotic Notation
Ω Notation
Assume, two functions f and g, so that
both are non-negative, and
both has non-negative arguments
Ω(g) :
{f |f is a non-negative function s.t. ∃
constants c and n0 s.t. 0 ≤ cg(n) ≤ f (n)}
for n ≥ n0
Asymptotic lower bound
Used to say an Algorithm shall take at least xyz time
Running time is Ω(f (n)) ⇒ Best case is Ω(f (n))
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 18 / 22
64. Introduction Asymptotic Notation
⃝ Notation
Assume, two functions f and g, so that
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 19 / 22
65. Introduction Asymptotic Notation
⃝ Notation
Assume, two functions f and g, so that
both are non-negative, and
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 19 / 22
66. Introduction Asymptotic Notation
⃝ Notation
Assume, two functions f and g, so that
both are non-negative, and
both has non-negative arguments
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 19 / 22
67. Introduction Asymptotic Notation
⃝ Notation
Assume, two functions f and g, so that
both are non-negative, and
both has non-negative arguments
⃝(g) :
{f |f is a non-negative function s.t. ∃
constants c and n0
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 19 / 22
68. Introduction Asymptotic Notation
⃝ Notation
Assume, two functions f and g, so that
both are non-negative, and
both has non-negative arguments
⃝(g) :
{f |f is a non-negative function s.t. ∃
constants c and n0 s.t. 0 ≤ f (n) ≤ cg(n)}
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 19 / 22
69. Introduction Asymptotic Notation
⃝ Notation
Assume, two functions f and g, so that
both are non-negative, and
both has non-negative arguments
⃝(g) :
{f |f is a non-negative function s.t. ∃
constants c and n0 s.t. 0 ≤ f (n) ≤ cg(n)}
for n ≥ n0
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 19 / 22
70. Introduction Asymptotic Notation
⃝ Notation
Assume, two functions f and g, so that
both are non-negative, and
both has non-negative arguments
⃝(g) :
{f |f is a non-negative function s.t. ∃
constants c and n0 s.t. 0 ≤ f (n) ≤ cg(n)}
for n ≥ n0
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 19 / 22
71. Introduction Asymptotic Notation
⃝ Notation
Assume, two functions f and g, so that
both are non-negative, and
both has non-negative arguments
⃝(g) :
{f |f is a non-negative function s.t. ∃
constants c and n0 s.t. 0 ≤ f (n) ≤ cg(n)}
for n ≥ n0
Asymptotic upper bound
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 19 / 22
72. Introduction Asymptotic Notation
⃝ Notation
Assume, two functions f and g, so that
both are non-negative, and
both has non-negative arguments
⃝(g) :
{f |f is a non-negative function s.t. ∃
constants c and n0 s.t. 0 ≤ f (n) ≤ cg(n)}
for n ≥ n0
Asymptotic upper bound
Used to say an Algorithm shall take at most xyz time
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 19 / 22
73. Introduction Asymptotic Notation
⃝ Notation
Assume, two functions f and g, so that
both are non-negative, and
both has non-negative arguments
⃝(g) :
{f |f is a non-negative function s.t. ∃
constants c and n0 s.t. 0 ≤ f (n) ≤ cg(n)}
for n ≥ n0
Asymptotic upper bound
Used to say an Algorithm shall take at most xyz time
Running time is ⃝(f (n)) ⇒ Worst case is ⃝(f (n))
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 19 / 22
77. Introduction Asymptotic Notation
Θ, Ω and ⃝ Notation
f (n) = Θ(g(n)) should be read as f (n) belongs to class Θ(g(n))
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 20 / 22
78. Introduction Asymptotic Notation
Θ, Ω and ⃝ Notation
f (n) = Θ(g(n)) should be read as f (n) belongs to class Θ(g(n))
or, f (n) is in class Θ(g(n))
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 20 / 22
79. Introduction Asymptotic Notation
Θ, Ω and ⃝ Notation
f (n) = Θ(g(n)) should be read as f (n) belongs to class Θ(g(n))
or, f (n) is in class Θ(g(n))
or, f (n) is Θ(g(n))
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 20 / 22
80. Introduction Asymptotic Notation
Θ, Ω and ⃝ Notation
f (n) = Θ(g(n)) should be read as f (n) belongs to class Θ(g(n))
or, f (n) is in class Θ(g(n))
or, f (n) is Θ(g(n))
Equality here is analogous to, for example, Rose is Red.
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 20 / 22
82. Introduction Asymptotic Notation
Examples
Q. Show that 1
2n2 − 3n = θ(n2)
We need to determine c1, c2 and n0 so that it satisfies the condition
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 21 / 22
83. Introduction Asymptotic Notation
Examples
Q. Show that 1
2n2 − 3n = θ(n2)
We need to determine c1, c2 and n0 so that it satisfies the condition :
c1n2 ≤ 1
2n2 − 3n ≤ c2n2
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 21 / 22
84. Introduction Asymptotic Notation
Examples
Q. Show that 1
2n2 − 3n = θ(n2)
We need to determine c1, c2 and n0 so that it satisfies the condition :
c1n2 ≤ 1
2n2 − 3n ≤ c2n2
for all n ≥ n0
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 21 / 22
85. Introduction Asymptotic Notation
Examples
Q. Show that 1
2n2 − 3n = θ(n2)
We need to determine c1, c2 and n0 so that it satisfies the condition :
c1n2 ≤ 1
2n2 − 3n ≤ c2n2
for all n ≥ n0
Dividing by n2 yields
c1 ≤
1
2
−
3
n
≤ c2
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 21 / 22
86. Introduction Asymptotic Notation
Examples
Q. Show that 1
2n2 − 3n = θ(n2)
We need to determine c1, c2 and n0 so that it satisfies the condition :
c1n2 ≤ 1
2n2 − 3n ≤ c2n2
for all n ≥ n0
Dividing by n2 yields
c1 ≤
1
2
−
3
n
≤ c2
The right-hand inequality can be hold for any value of n ≥ 1 by choosing
c2 ≥ 1
2.
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 21 / 22
87. Introduction Asymptotic Notation
Examples
Q. Show that 1
2n2 − 3n = θ(n2)
We need to determine c1, c2 and n0 so that it satisfies the condition :
c1n2 ≤ 1
2n2 − 3n ≤ c2n2
for all n ≥ n0
Dividing by n2 yields
c1 ≤
1
2
−
3
n
≤ c2
The right-hand inequality can be hold for any value of n ≥ 1 by choosing
c2 ≥ 1
2.
The left-hand inequality can be hold for any value of n ≥ 7 by choosing
c1 ≤ 1
14
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 21 / 22
88. Introduction Asymptotic Notation
Examples
Q. Show that 1
2n2 − 3n = θ(n2)
We need to determine c1, c2 and n0 so that it satisfies the condition :
c1n2 ≤ 1
2n2 − 3n ≤ c2n2
for all n ≥ n0
Dividing by n2 yields
c1 ≤
1
2
−
3
n
≤ c2
The right-hand inequality can be hold for any value of n ≥ 1 by choosing
c2 ≥ 1
2.
The left-hand inequality can be hold for any value of n ≥ 7 by choosing
c1 ≤ 1
14
Thus, by choosing c1 = 1
14, c2 = 1
2 and n0 = 7, we can prove that
1
2n2 − 3n = θ(n2).
Dr. Hemanta Kumar Kalita Algorithm Analysis and Design January 9, 2025 21 / 22