This document discusses asymptotic analysis and big-O notation for analyzing the time complexity of algorithms. It begins by defining key concepts like growth rate, asymptotic notations such as O(n), Ω(n) and Θ(n). It then provides examples of analyzing the time efficiency of different algorithms like finding the maximum element in an array and computing prefix averages. The document explains how to determine the asymptotic complexity by counting the total number of operations and expressing it using big-O notation. It also discusses properties of big-O notation like rules for dropping constant factors and lower order terms.
Unit 1: Fundamentals of the Analysis of Algorithmic Efficiency, Units for Measuring Running Time, PROPERTIES OF AN ALGORITHM, Growth of Functions, Algorithm - Analysis, Asymptotic Notations, Recurrence Relation and problems
Unit 1: Fundamentals of the Analysis of Algorithmic Efficiency, Units for Measuring Running Time, PROPERTIES OF AN ALGORITHM, Growth of Functions, Algorithm - Analysis, Asymptotic Notations, Recurrence Relation and problems
Growth of Functions
CMSC 56 | Discrete Mathematical Structure for Computer Science
October 6, 2018
Instructor: Allyn Joy D. Calcaben
College of Arts & Sciences
University of the Philippines Visayas
Palestine last event orientationfvgnh .pptxRaedMohamed3
An EFL lesson about the current events in Palestine. It is intended to be for intermediate students who wish to increase their listening skills through a short lesson in power point.
Growth of Functions
CMSC 56 | Discrete Mathematical Structure for Computer Science
October 6, 2018
Instructor: Allyn Joy D. Calcaben
College of Arts & Sciences
University of the Philippines Visayas
Palestine last event orientationfvgnh .pptxRaedMohamed3
An EFL lesson about the current events in Palestine. It is intended to be for intermediate students who wish to increase their listening skills through a short lesson in power point.
The Art Pastor's Guide to Sabbath | Steve ThomasonSteve Thomason
What is the purpose of the Sabbath Law in the Torah. It is interesting to compare how the context of the law shifts from Exodus to Deuteronomy. Who gets to rest, and why?
How to Create Map Views in the Odoo 17 ERPCeline George
The map views are useful for providing a geographical representation of data. They allow users to visualize and analyze the data in a more intuitive manner.
How to Split Bills in the Odoo 17 POS ModuleCeline George
Bills have a main role in point of sale procedure. It will help to track sales, handling payments and giving receipts to customers. Bill splitting also has an important role in POS. For example, If some friends come together for dinner and if they want to divide the bill then it is possible by POS bill splitting. This slide will show how to split bills in odoo 17 POS.
Read| The latest issue of The Challenger is here! We are thrilled to announce that our school paper has qualified for the NATIONAL SCHOOLS PRESS CONFERENCE (NSPC) 2024. Thank you for your unwavering support and trust. Dive into the stories that made us stand out!
The Roman Empire A Historical Colossus.pdfkaushalkr1407
The Roman Empire, a vast and enduring power, stands as one of history's most remarkable civilizations, leaving an indelible imprint on the world. It emerged from the Roman Republic, transitioning into an imperial powerhouse under the leadership of Augustus Caesar in 27 BCE. This transformation marked the beginning of an era defined by unprecedented territorial expansion, architectural marvels, and profound cultural influence.
The empire's roots lie in the city of Rome, founded, according to legend, by Romulus in 753 BCE. Over centuries, Rome evolved from a small settlement to a formidable republic, characterized by a complex political system with elected officials and checks on power. However, internal strife, class conflicts, and military ambitions paved the way for the end of the Republic. Julius Caesar’s dictatorship and subsequent assassination in 44 BCE created a power vacuum, leading to a civil war. Octavian, later Augustus, emerged victorious, heralding the Roman Empire’s birth.
Under Augustus, the empire experienced the Pax Romana, a 200-year period of relative peace and stability. Augustus reformed the military, established efficient administrative systems, and initiated grand construction projects. The empire's borders expanded, encompassing territories from Britain to Egypt and from Spain to the Euphrates. Roman legions, renowned for their discipline and engineering prowess, secured and maintained these vast territories, building roads, fortifications, and cities that facilitated control and integration.
The Roman Empire’s society was hierarchical, with a rigid class system. At the top were the patricians, wealthy elites who held significant political power. Below them were the plebeians, free citizens with limited political influence, and the vast numbers of slaves who formed the backbone of the economy. The family unit was central, governed by the paterfamilias, the male head who held absolute authority.
Culturally, the Romans were eclectic, absorbing and adapting elements from the civilizations they encountered, particularly the Greeks. Roman art, literature, and philosophy reflected this synthesis, creating a rich cultural tapestry. Latin, the Roman language, became the lingua franca of the Western world, influencing numerous modern languages.
Roman architecture and engineering achievements were monumental. They perfected the arch, vault, and dome, constructing enduring structures like the Colosseum, Pantheon, and aqueducts. These engineering marvels not only showcased Roman ingenuity but also served practical purposes, from public entertainment to water supply.
Ethnobotany and Ethnopharmacology:
Ethnobotany in herbal drug evaluation,
Impact of Ethnobotany in traditional medicine,
New development in herbals,
Bio-prospecting tools for drug discovery,
Role of Ethnopharmacology in drug evaluation,
Reverse Pharmacology.
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxEduSkills OECD
Andreas Schleicher presents at the OECD webinar ‘Digital devices in schools: detrimental distraction or secret to success?’ on 27 May 2024. The presentation was based on findings from PISA 2022 results and the webinar helped launch the PISA in Focus ‘Managing screen time: How to protect and equip students against distraction’ https://www.oecd-ilibrary.org/education/managing-screen-time_7c225af4-en and the OECD Education Policy Perspective ‘Students, digital devices and success’ can be found here - https://oe.cd/il/5yV
The French Revolution, which began in 1789, was a period of radical social and political upheaval in France. It marked the decline of absolute monarchies, the rise of secular and democratic republics, and the eventual rise of Napoleon Bonaparte. This revolutionary period is crucial in understanding the transition from feudalism to modernity in Europe.
For more information, visit-www.vavaclasses.com
How to Make a Field invisible in Odoo 17Celine George
It is possible to hide or invisible some fields in odoo. Commonly using “invisible” attribute in the field definition to invisible the fields. This slide will show how to make a field invisible in odoo 17.
2. Objectives
• Understanding Growth Rate
• Functions of Growth Rate
• Asymptotic Notations
• Analyzing Time Efficiency of algorithms and representing in appropriate asymptotic notation
• Examples
3. Analysis: Performance
DESIGN AND ANALYSIS OF ALGORITHMS 3
o We can determine the maximum number of
primitive/basic operations executed by an algorithm, as a
function of the input size.
Algorithm arrayMax(A, n)
# operations
currentMax A[0] 2
for (i =1; i<n; i++) 2n
(i=1 once, i<n n times, i++ (n-1) times:post increment)
if A[i] currentMax then 2(n 1)
currentMax A[i] 2(n 1)
return currentMax 1
Total 6n 1
4. Analysis: Performance
Algorithm arrayMax executes 6n 1 primitive operations in the
worst case.
Define:
a = Time taken by the fastest primitive operation
b = Time taken by the slowest primitive operation
Let T(n) be worst-case time of arrayMax. Then
a (6n 1) T(n) b(6n 1 )
Hence, the running time T(n) is bounded by two linear functions
DESIGN AND ANALYSIS OF ALGORITHMS 4
5. Growth Rate of Running Time
DESIGN AND ANALYSIS OF ALGORITHMS 5
• Affects T(n) by a constant factor, but
• Does not alter the growth rate of T(n)
Changing the hardware/ software environment
• The linear growth rate of the running time T(n) is an intrinsic property of algorithm arrayMax
Intrinsic Property
• Growth rate simplifies the Time Efficiency analysis and mechanism to compare algorithms
Analysis and Comparison
6. Seven
Important
Functions
Constant 1
Logarithmic log n
Linear n
N-Log-N n log n
Quadratic n2
Cubic n3
Exponential 2n
These seven functions that often appear in algorithm
analysis.
In a chart, the slope of the line corresponds to the growth
rate of the function
DESIGN AND ANALYSIS OF ALGORITHMS 6
1E-1
1E+1
1E+3
1E+5
1E+7
1E+9
1E+11
1E+13
1E+15
1E+17
1E+19
1E+21
1E+23
1E+25
1E+27
1E+29
1E-1 1E+2 1E+5 1E+8
T(n)
n
Cubic
Quadratic
Linear
8. Execution Times
(one time constant is 1 nano seconds)
n f(n) = lgn f(n) = n f(n) = nlgn f(n) = n2
f(n) = n3
f(n) = 2n
1 0 0.003 micro sec 0.01 micro sec 0.033 micro sec 0.1 micro sec 1 micro sec 1 micro sec
2 0 0.004 micro sec 0.02 micro sec 0.086 micro sec 0.4micro sec 8 micro sec 1 milli sec
3 0 0.005 micro sec 0.03 micro sec 0.147 micro sec 0.9 micro sec 27micro sec 1 sec
4 0 0.005 micro sec 0.04 micro sec 0.213 micro sec 1.6 micro sec 64 micro sec 18.3 min
5 0 0.006 micro sec 0.05 micro sec 0.282 micro sec 2.5 micro sec 125 micro sec 13 days
1 02
0.007 micro sec 0.10 micro sec 0.664 micro sec 10 micro sec 1 milli sec 4 exp 13 years
1 03
0.010 micro sec 1.00 micro sec 9.966 micro sec 1 milli sec 1 sec
1 04
0.013 micro sec 10 micro sec 130 micro sec 100 milli sec 16.7 min
1 05
0.017 micro sec 0.10 milli sec 1.67 milli sec 10 s 11.6 days
1 06
0.020 micro sec 1 milli sec 19.93 milli sec 16.7 min 31.7 years
1 07
0.023 micro sec 0.01sec 0.23 sec 1.16 days 31709 years
1 08
0.027 micro sec 0.10 sec 2.66 sec 115.7 days 3.17 exp 7 years
1 09
0.030 micro sec 1 sec 29.90 sec 31.7 years
9. Constant Factors
DESIGN AND ANALYSIS OF ALGORITHMS 9
The growth rate is not affected by
Constant factors or lower-order terms
Select Only higher order term
Examples
102n + 105 is a linear function
105n2 + 108n is a quadratic function
10. Asymptotic Notations
• In Mathematics, The term asymptotic means approaching a value or curve arbitrarily
closely (i.e., as some sort of limit is taken).
• Asymptotic analysis, is a method of describing limiting behavior. As an illustration,
suppose that we are interested in the properties of a function f as n becomes very
large. i.e., growth rate.
• Big Oh (O)
• Omega ()
• Theta ()
DESIGN AND ANALYSIS OF ALGORITHMS 10
11. Big-Oh Notation)
Given functions f(n) and g(n),
f(n) = O(g(n)) iff there exist two positive
constants c and n0 such that
f(n) <= cg(n) for all n >= n0
g(n) is an asymptotic upper bound on f(n).
Example: 2n + 10 is O(n)
◦ 2n + 10 cn
◦ (c 2) n 10
◦ n 10/(c 2)
◦ Pick c = 3 and n0 = 10
DESIGN AND ANALYSIS OF ALGORITHMS 11
Tt
1 n
g(n)
f(n)
n0
12. Big-Oh Example
Example: the function n2 is
not O(n)
◦ n2 cn
◦ n c
◦ The above inequality cannot
be satisfied since c must be a
constant
DESIGN AND ANALYSIS OF ALGORITHMS 12
1
10
100
1,000
10,000
100,000
1,000,000
1 10 100 1,000
n
n^2
100n
10n
n
13. DESIGN AND ANALYSIS OF ALGORITHMS 13
More Big-Oh Examples
7n-2
7n-2 is O(n)
need c > 0 and n0 1 such that 7n-2 c•n for n n0
this is true for c = 7 and n0 = 1
3n3 + 20n2 + 5
3n3 + 20n2 + 5 is O(n3)
need c > 0 and n0 1 such that 3n3 + 20n2 + 5 c•n3 for n n0
this is true for c = 4 and n0 = 21
3 log n + 5
3 log n + 5 is O(log n)
need c > 0 and n0 1 such that 3 log n + 5 c•log n for n n0
this is true for c = 8 and n0 = 2
14. Big-Oh and
Growth Rate
The big-Oh notation gives an upper
bound on the growth rate of a
function
The statement “f(n) is O(g(n))” means
that the growth rate of f(n) is no more
than the growth rate of g(n)
We can use the big-Oh notation to
rank functions according to their
growth rate
DESIGN AND ANALYSIS OF ALGORITHMS 14
f(n) is
O(g(n))
g(n) is
O(f(n))
g(n) grows
more
Yes No
f(n) grows
more
No Yes
Same
growth
Yes Yes
15. Big-Oh Rules
DESIGN AND ANALYSIS OF ALGORITHMS 15
Use the simplest expression of the class
Say “3n + 5 is O(n)” instead of “3n + 5 is O(3n)”
Use the smallest possible class of functions
Say “2n is O(n)” instead of “2n is O(n2)”
If is f(n) a polynomial of degree d, then f(n) is O(nd), i.e.,
Drop
•Lower-order terms
•Constant factors
Examples:
T(n) = O(2n2) -------- wrong
T(n) = O(n2 + n) ----- wrong
16. Big-Oh Rules
DESIGN AND ANALYSIS OF ALGORITHMS 16
If T(x) is a polynomial of degree n, then
T(x) = (xn)
T1(n) * T2(n) = O( f(n) * g(n) )
If T1(n) = O(f(n)) and T2(n) = O(g(n))
Then T1(n) + T2(n) = Max(O(f(n)), O(g(n)))
17. Asymptotic
Algorithm
Analysis
The asymptotic analysis of an algorithm determines the running time
in big-Oh notation
To perform the asymptotic analysis
◦ We find the worst-case number of primitive operations executed as
a function of the input size (Total Running Time)
◦ We express this function with big-Oh notation
Example:
◦ We determine that algorithm arrayMax executes at most 8n 2
primitive operations
◦ We say that algorithm arrayMax “runs in O(n) time”
Since constant factors and lower-order terms are eventually dropped
anyhow, we can disregard them when counting primitive operations
DESIGN AND ANALYSIS OF ALGORITHMS 17
18. Example: Computing Prefix Averages
We further illustrate asymptotic
analysis with two algorithms for
prefix averages
The i-th prefix average of an array
X is average of the first (i + 1)
elements of X:
A[i] = (X[0] + X[1] + … + X[i])/(i+1)
Computing the array A of prefix
averages of another array X has
applications to financial analysis
DESIGN AND ANALYSIS OF ALGORITHMS 18
0
5
10
15
20
25
30
35
1 2 3 4 5 6 7
X
A
19. DESIGN AND ANALYSIS OF ALGORITHMS 19
Prefix Averages (Quadratic)
The following algorithm computes prefix averages in quadratic time
Algorithm prefixAverages1(X, n)
Input array X of n integers
Output array A of prefix averages of X #operations
A new array of n integers n
for i 0 to n 1 do n
s X[0] n
for j 1 to i do 1 + 2 + …+ (n 1)
s s + X[j] 1 + 2 + …+ (n 1)
A[i] s / (i + 1) n
return A 1
20. Arithmetic Progression
The running time of
prefixAverages1 is
O(1 + 2 + …+ n)
The sum of the first n integers
is n(n + 1) / 2
◦ There is a simple visual proof of
this fact
Thus, algorithm
prefixAverages1 runs in O(n2)
time
DESIGN AND ANALYSIS OF ALGORITHMS 20
0
1
2
3
4
5
6
7
1 2 3 4 5 6
21. DESIGN AND ANALYSIS OF ALGORITHMS 21
Prefix Averages (Linear)
The following algorithm computes prefix averages in
linear time by keeping a running sum
Algorithm prefixAverages2(X, n)
Input array X of n integers
Output array A of prefix averages of X #operations
A new array of n integers n
s 0 1
for i 0 to n 1 do n
s s + X[i] n
A[i] s / (i + 1) n
return A 1
Algorithm prefixAverages2 runs in O(n) time
22. DESIGN AND ANALYSIS OF ALGORITHMS 22
Relatives of Big-Oh
big-Omega
f(n) is (g(n)) iff there is a constant c > 0
and an integer constant n0 1 such that
f(n) c•g(n) for n n0
big-Theta
f(n) is (g(n)) iff there are constants
c’ > 0 and c’’ > 0 and an integer constant
n0 1 such that
c’•g(n) f(n) c’’•g(n) for n n0
n
n0
f(n)
g(n)
n
n0
c2g(n)
c1g(n)
f(n)
23. Intuition for Asymptotic
Notation
DESIGN AND ANALYSIS OF ALGORITHMS 23
Big-Oh
f(n) is O(g(n)) if f(n) is asymptotically
less than or equal to g(n)
big-Omega
f(n) is (g(n)) if f(n) is asymptotically
greater than or equal to g(n)
big-Theta
f(n) is (g(n)) if f(n) is asymptotically
equal to g(n)
24. DESIGN AND ANALYSIS OF ALGORITHMS 24
Example Uses of the
Relatives of Big-Oh
f(n) is (g(n)) if it is (n2) and O(n2). We have already seen the former,
for the latter recall that f(n) is O(g(n)) if there is a constant c > 0 and an
integer constant n0 1 such that f(n) < c•g(n) for n n0
Let c = 5 and n0 = 1
5n2 is (n2)
f(n) is (g(n)) if there is a constant c > 0 and an integer constant n0 1
such that f(n) c•g(n) for n n0
let c = 1 and n0 = 1
5n2 is (n)
f(n) is (g(n)) if there is a constant c > 0 and an integer constant n0 1
such that f(n) c•g(n) for n n0
let c = 5 and n0 = 1
5n2 is (n2)