SlideShare une entreprise Scribd logo
1  sur  19
III.PERFORMANCE ANALYSIS
Performance analysis of an algorithm
depends upon two factors
i amount of memory used
ii amount of compute time consumed on
any CPU.
Formally they are notified as complexities
in terms of:
1.Space Complexity.
2.Time Complexity.
Space Complexity of an algorithm is the amount of memory it
needs to run to completion i.e. from start of execution to its
termination. Space need by any algorithm is the sum of
following components:
Fixed Component: This is independent of the characteristics
of the inputs and outputs.
This part includes: Instruction Space, Space of simple
variables, fixed size component variables, and constants
variables.
Variable Component: This consist of the space needed by
component variables whose size is dependent on the particular
problems instances(Inputs/Outputs) being solved, the space
needed by referenced variables and the recursion stack space
is one of the most prominent components. Also this included
the data structure components like Linked list, heap, trees,
graphs etc.
Therefore the total space requirement of any algorithm 'A' can
be provided as
Space(A) = Fixed Components(A) + Variable Components(A)
Among both fixed and variable component the variable part is
important to be determined accurately, so that the actual space
requirement can be identified for an algorithm 'A'. To identify
the space complexity of any algorithm following steps can be
followed:
Determine the variables which are instantiated by some default
values.
Determine which instance characteristics should be used to
measure the space requirement and this is will be problem
specific.
Generally the choices are limited to quantities related to the
number and magnitudes of the inputs to and outputs from the
algorithms.
Sometimes more complex measures of the interrelationships
among the data items can used.
Example: Space Complexity
Algorithm Sum(number , size) procedure will
produce sum of all numbers provided in 'number' list
{
result=0.0;
for count = 1 to size do will repeat from 1,2,3,4,....size
times
result= result + number[count];
return result;
}
In above example, when calculating the space
complexity we will be looking for both fixed and variable
components. here we have
Fixed components as 'result','count' and 'size' variable
there for total space required is three(3) words.
Variable components is characterized as the
value stored in 'size' variable (suppose value
store in variable 'size 'is 'n'). because this will
decide the size of 'number' list and will also
drive the for loop. therefore if the space used
by size is one word then the total space
required by 'number' variable will be 'n'(value
stored in variable 'size').
therefore the space complexity can be written as
Space(Sum) = 3 + n;
Time Complexity of an algorithm(basically when
converted to program) is the amount of computer
time it needs to run to completion.
The time taken by a program is the sum of
the compile time and the run/execution time
.The compile time is independent of the
instance(problem specific) characteristics.
following factors effect the time complexity:
Characteristics of compiler used to compile the
program.
Computer Machine on which the program is
executed and physically clocked.
Multiuser execution system.
Number of program steps.
Therefore the again the time complexity consist of two
components fixed(factor 1 only) and variable/instance(factor
2,3 & 4), so for any algorithm 'A' it is provided as:
Time(A) = Fixed Time(A) + Instance Time(A)
Here the number of steps is the most prominent instance
characteristics and The number of steps any program statement
is assigned depends on the kind of statement like
comments count as zero steps,
an assignment statement which does not involve any calls to other
algorithm is counted as one step,
for iterative statements we consider the steps count only for the
control part of the statement etc.
Therefore to calculate total number program of program steps we
use following procedure. For this we build a table in which we list
the total number of steps contributed by each statement. This is
often arrived at by first determining the number of steps per
execution of the statement and the frequency of each statement
executed. This procedure is explained using an example.
Example: Time Complexity
Statement
Steps
per
execution
Frequenc
y
Total
Steps
Algorithm Sum(number,size)
0 -
0
{ 0 - 0
result=0.0;
1 1 1
for count = 1 to size do
1
size+
1
size + 1
result= result + number[count];
1 size size
return result;
1 1 1
} 0 - 0
Total
2size +
3
In above example if you analyze carefully frequency of "for
count = 1 to size do" it is 'size +1' this is because the
statement will be executed one time more die to condition
check for false situation of condition provided in for
statement. Now once the total steps are calculated they
will resemble the instance characteristics in time
complexity of algorithm. Also the repeated compile time of
an algorithm will also be constant every time we compile
the same set of instructions so we can consider this time
as constant 'C'. Therefore the time complexity can be
expressed as: Time(Sum) = C + (2size +3)
So in this way both the Space complexity and Time
complexity can be calculated. Combination of both
complexity comprises the Performance analysis of any
algorithm and can not be used independently. Both these
complexities also helps in defining parameters on basis of
which we optimize algorithms.
Processing Speed
In the computer world, frequency is often
used to measure processing speed. For
example, clock speed, measures how many
cycles a processor can complete in one
second. If a computer has a 3.2GHz
processor, it can can complete
3,200,000,000 cycles per second. FLOPS,
which is used to measure floating
point performance, is also a frequency-based
calculation (operations per second). Finally,
computing speed may also be defined
in MIPS, which measures instructions per
second.
Complexity of Algorithms
The complexity of an algorithm M is the function f(n)
which gives the running time and/or storage space
requirement of the algorithm in terms of the size ‘n’ of
the input data. Mostly, the storage space required by
an algorithm is simply a multiple of the data size ‘n’.
Complexity shall refer to the running time of the
algorithm.
The function f(n), gives the running time of an
algorithm, depends not only on the size ‘n’ of the input
data but also on the particular data. The complexity
function f(n) for certain cases are:
•Best Case: The minimum possible value of f(n) is
called the best case.
•Average Case : The expected value of f(n).
Worst Case: The maximum value of f(n) for any key
possible input.
Asymptotic Notations
The following notations are commonly use notations in
performance analysis and used to characterize the
complexity of an algorithm:
•Big–OH (O) ,
•Big–OMEGA (Ω),
•Big–THETA ( ) and
•Little–OH (o)
Big Oh Notation, Ο
The notation Ο(n) is the formal way to express the upper bound of an algorithm's
running time. It measures the worst case time complexity or the longest amount of
time an algorithm can possibly take to complete.
For example, for a function f(n)
Ο(f(n)) = { g(n) : there exists c > 0 and n0 such that f(n) ≤ c.g(n) for all n > n0. }
Omega Notation, Ω
The notation Ω(n) is the formal way to express the lower bound
of an algorithm's running time. It measures the best case time
complexity or the best amount of time an algorithm can
possibly take to complete.
For example, for a function f(n)
Ω(f(n)) ≥ { g(n) : there exists c > 0 and n0 such that g(n) ≤ c.f(n)
for all n > n0. }
Theta Notation, θ
The notation θ(n) is the formal way to express both the
lower bound and the upper bound of an algorithm's
running time. It is represented as follows −θ(f(n)) = {
g(n) if and only if g(n) = Ο(f(n)) and g(n) = Ω(f(n)) for all
n > n0. }
Amortized Analysis is used for algorithms where an
occasional operation is very slow, but most of the other
operations are faster. In Amortized Analysis, we
analyze a sequence of operations and guarantee a
worst case average time which is lower than the worst
case time of a particular expensive operation.
Aggregate Method
The aggregate method is used to find the total cost. If we want to
add a bunch of data, then we need to find the amortized cost by
this formula.
For a sequence of n operations, the cost is −
Let us consider an example of a simple hash table insertions. How
do we decide table size? There is a trade-off between space and
time, if we make hash-table size big, search time becomes fast,
but space required becomes high.
The solution to this trade-off problem is to use Dynamic Table (or Arrays).
The idea is to increase size of table whenever it becomes full. Following are
the steps to follow when table becomes full.
1) Allocate memory for a larger table of size, typically twice the old table.
2) Copy the contents of old table to new table.
3) Free the old table.
If the table has space available, we simply insert new item in available space.
What is the time complexity of n insertions using the above scheme?
If we use simple analysis, the worst case cost of an insertion is O(n). Therefore,
worst case cost of n inserts is n * O(n) which is O(n2). This analysis gives an
upper bound, but not a tight upper bound for n insertions as all insertions
don’t take Θ(n) time.
So using Amortized Analysis, we could prove
that the Dynamic Table scheme has O(1)
insertion time which is a great result used in
hashing.
Randomized Algorithms
An algorithm that uses random numbers to decide what to do next
anywhere in its logic is called Randomized Algorithm.
Classification
Randomized algorithms are classified in two categories.
Las Vegas: These algorithms always produce correct or optimum
result. Time complexity of these algorithms is based on a random
value and time complexity is evaluated as expected value.
Monte Carlo: Produce correct or optimum result with some
probability. These algorithms have deterministic running time and
it is generally easier to find out worst case time complexity.
Applications
Graph algorithms: Minimum spanning trees, shortest
paths, minimum cuts.
Counting and enumeration: Matrix permanent Counting
combinatorial structures.
Parallel and distributed computing: Deadlock avoidance
distributed consensus.
Probabilistic existence proofs: Show that a combinatorial object
arises with non-zero probability among objects drawn from a
suitable probability space.

Contenu connexe

Tendances

sum of subset problem using Backtracking
sum of subset problem using Backtrackingsum of subset problem using Backtracking
sum of subset problem using BacktrackingAbhishek Singh
 
Directed Acyclic Graph Representation of basic blocks
Directed Acyclic Graph Representation of basic blocksDirected Acyclic Graph Representation of basic blocks
Directed Acyclic Graph Representation of basic blocksMohammad Vaseem Akaram
 
15 puzzle problem using branch and bound
15 puzzle problem using branch and bound15 puzzle problem using branch and bound
15 puzzle problem using branch and boundAbhishek Singh
 
class and objects
class and objectsclass and objects
class and objectsPayel Guria
 
Nondeterministic Finite Automata
Nondeterministic Finite AutomataNondeterministic Finite Automata
Nondeterministic Finite AutomataAdel Al-Ofairi
 
Graph representation
Graph representationGraph representation
Graph representationTech_MX
 
DESIGN AND ANALYSIS OF ALGORITHMS
DESIGN AND ANALYSIS OF ALGORITHMSDESIGN AND ANALYSIS OF ALGORITHMS
DESIGN AND ANALYSIS OF ALGORITHMSGayathri Gaayu
 
Three Address code
Three Address code Three Address code
Three Address code Pooja Dixit
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notationsNikhil Sharma
 
Depth first search [dfs]
Depth first search [dfs]Depth first search [dfs]
Depth first search [dfs]DEEPIKA T
 
01 Knapsack using Dynamic Programming
01 Knapsack using Dynamic Programming01 Knapsack using Dynamic Programming
01 Knapsack using Dynamic ProgrammingFenil Shah
 
Graph coloring problem(DAA).pptx
Graph coloring problem(DAA).pptxGraph coloring problem(DAA).pptx
Graph coloring problem(DAA).pptxHome
 

Tendances (20)

sum of subset problem using Backtracking
sum of subset problem using Backtrackingsum of subset problem using Backtracking
sum of subset problem using Backtracking
 
Directed Acyclic Graph Representation of basic blocks
Directed Acyclic Graph Representation of basic blocksDirected Acyclic Graph Representation of basic blocks
Directed Acyclic Graph Representation of basic blocks
 
Backtracking
BacktrackingBacktracking
Backtracking
 
Double ended queue
Double ended queueDouble ended queue
Double ended queue
 
Branch and bound
Branch and boundBranch and bound
Branch and bound
 
15 puzzle problem using branch and bound
15 puzzle problem using branch and bound15 puzzle problem using branch and bound
15 puzzle problem using branch and bound
 
Back patching
Back patchingBack patching
Back patching
 
class and objects
class and objectsclass and objects
class and objects
 
N queen problem
N queen problemN queen problem
N queen problem
 
Nondeterministic Finite Automata
Nondeterministic Finite AutomataNondeterministic Finite Automata
Nondeterministic Finite Automata
 
Graph representation
Graph representationGraph representation
Graph representation
 
DESIGN AND ANALYSIS OF ALGORITHMS
DESIGN AND ANALYSIS OF ALGORITHMSDESIGN AND ANALYSIS OF ALGORITHMS
DESIGN AND ANALYSIS OF ALGORITHMS
 
Three Address code
Three Address code Three Address code
Three Address code
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
 
Depth first search [dfs]
Depth first search [dfs]Depth first search [dfs]
Depth first search [dfs]
 
Asymptotic Notation
Asymptotic NotationAsymptotic Notation
Asymptotic Notation
 
01 Knapsack using Dynamic Programming
01 Knapsack using Dynamic Programming01 Knapsack using Dynamic Programming
01 Knapsack using Dynamic Programming
 
Graph coloring problem(DAA).pptx
Graph coloring problem(DAA).pptxGraph coloring problem(DAA).pptx
Graph coloring problem(DAA).pptx
 
Spanning trees
Spanning treesSpanning trees
Spanning trees
 
SINGLE-SOURCE SHORTEST PATHS
SINGLE-SOURCE SHORTEST PATHS SINGLE-SOURCE SHORTEST PATHS
SINGLE-SOURCE SHORTEST PATHS
 

Similaire à Performance analysis and randamized agoritham

Unit i basic concepts of algorithms
Unit i basic concepts of algorithmsUnit i basic concepts of algorithms
Unit i basic concepts of algorithmssangeetha s
 
TIME EXECUTION OF DIFFERENT SORTED ALGORITHMS
TIME EXECUTION   OF  DIFFERENT SORTED ALGORITHMSTIME EXECUTION   OF  DIFFERENT SORTED ALGORITHMS
TIME EXECUTION OF DIFFERENT SORTED ALGORITHMSTanya Makkar
 
Module 1 notes of data warehousing and data
Module 1 notes of data warehousing and dataModule 1 notes of data warehousing and data
Module 1 notes of data warehousing and datavijipersonal2012
 
Data Structure & Algorithms - Mathematical
Data Structure & Algorithms - MathematicalData Structure & Algorithms - Mathematical
Data Structure & Algorithms - Mathematicalbabuk110
 
Lecture 03 algorithm analysis
Lecture 03 algorithm analysisLecture 03 algorithm analysis
Lecture 03 algorithm analysisNurjahan Nipa
 
VCE Unit 01 (2).pptx
VCE Unit 01 (2).pptxVCE Unit 01 (2).pptx
VCE Unit 01 (2).pptxskilljiolms
 
Algorithm Analysis.pdf
Algorithm Analysis.pdfAlgorithm Analysis.pdf
Algorithm Analysis.pdfMemMem25
 
DSA Complexity.pptx What is Complexity Analysis? What is the need for Compl...
DSA Complexity.pptx   What is Complexity Analysis? What is the need for Compl...DSA Complexity.pptx   What is Complexity Analysis? What is the need for Compl...
DSA Complexity.pptx What is Complexity Analysis? What is the need for Compl...2022cspaawan12556
 
Asymptotic Analysis in Data Structure using C
Asymptotic Analysis in Data Structure using CAsymptotic Analysis in Data Structure using C
Asymptotic Analysis in Data Structure using CMeghaj Mallick
 
Aad introduction
Aad introductionAad introduction
Aad introductionMr SMAK
 
Data structure and algorithm
Data structure and algorithmData structure and algorithm
Data structure and algorithmTrupti Agrawal
 
Fundamentals of the Analysis of Algorithm Efficiency
Fundamentals of the Analysis of Algorithm EfficiencyFundamentals of the Analysis of Algorithm Efficiency
Fundamentals of the Analysis of Algorithm EfficiencySaranya Natarajan
 
Data Structures - Lecture 8 - Study Notes
Data Structures - Lecture 8 - Study NotesData Structures - Lecture 8 - Study Notes
Data Structures - Lecture 8 - Study NotesHaitham El-Ghareeb
 
Asymptotic Notations
Asymptotic NotationsAsymptotic Notations
Asymptotic NotationsNagendraK18
 
Measuring algorithm performance
Measuring algorithm performanceMeasuring algorithm performance
Measuring algorithm performanceHabitamuAsimare
 

Similaire à Performance analysis and randamized agoritham (20)

Unit i basic concepts of algorithms
Unit i basic concepts of algorithmsUnit i basic concepts of algorithms
Unit i basic concepts of algorithms
 
TIME EXECUTION OF DIFFERENT SORTED ALGORITHMS
TIME EXECUTION   OF  DIFFERENT SORTED ALGORITHMSTIME EXECUTION   OF  DIFFERENT SORTED ALGORITHMS
TIME EXECUTION OF DIFFERENT SORTED ALGORITHMS
 
Module 1 notes of data warehousing and data
Module 1 notes of data warehousing and dataModule 1 notes of data warehousing and data
Module 1 notes of data warehousing and data
 
Data Structure & Algorithms - Mathematical
Data Structure & Algorithms - MathematicalData Structure & Algorithms - Mathematical
Data Structure & Algorithms - Mathematical
 
Lecture 03 algorithm analysis
Lecture 03 algorithm analysisLecture 03 algorithm analysis
Lecture 03 algorithm analysis
 
VCE Unit 01 (2).pptx
VCE Unit 01 (2).pptxVCE Unit 01 (2).pptx
VCE Unit 01 (2).pptx
 
Algorithm Analysis.pdf
Algorithm Analysis.pdfAlgorithm Analysis.pdf
Algorithm Analysis.pdf
 
DSA Complexity.pptx What is Complexity Analysis? What is the need for Compl...
DSA Complexity.pptx   What is Complexity Analysis? What is the need for Compl...DSA Complexity.pptx   What is Complexity Analysis? What is the need for Compl...
DSA Complexity.pptx What is Complexity Analysis? What is the need for Compl...
 
Complexity
ComplexityComplexity
Complexity
 
Unit ii algorithm
Unit   ii algorithmUnit   ii algorithm
Unit ii algorithm
 
Asymptotic Analysis in Data Structure using C
Asymptotic Analysis in Data Structure using CAsymptotic Analysis in Data Structure using C
Asymptotic Analysis in Data Structure using C
 
Algorithm.pptx
Algorithm.pptxAlgorithm.pptx
Algorithm.pptx
 
Algorithm.pptx
Algorithm.pptxAlgorithm.pptx
Algorithm.pptx
 
Aad introduction
Aad introductionAad introduction
Aad introduction
 
Analysis of algorithms
Analysis of algorithmsAnalysis of algorithms
Analysis of algorithms
 
Data structure and algorithm
Data structure and algorithmData structure and algorithm
Data structure and algorithm
 
Fundamentals of the Analysis of Algorithm Efficiency
Fundamentals of the Analysis of Algorithm EfficiencyFundamentals of the Analysis of Algorithm Efficiency
Fundamentals of the Analysis of Algorithm Efficiency
 
Data Structures - Lecture 8 - Study Notes
Data Structures - Lecture 8 - Study NotesData Structures - Lecture 8 - Study Notes
Data Structures - Lecture 8 - Study Notes
 
Asymptotic Notations
Asymptotic NotationsAsymptotic Notations
Asymptotic Notations
 
Measuring algorithm performance
Measuring algorithm performanceMeasuring algorithm performance
Measuring algorithm performance
 

Dernier

The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...RKavithamani
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 

Dernier (20)

The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 

Performance analysis and randamized agoritham

  • 1. III.PERFORMANCE ANALYSIS Performance analysis of an algorithm depends upon two factors i amount of memory used ii amount of compute time consumed on any CPU. Formally they are notified as complexities in terms of: 1.Space Complexity. 2.Time Complexity.
  • 2. Space Complexity of an algorithm is the amount of memory it needs to run to completion i.e. from start of execution to its termination. Space need by any algorithm is the sum of following components: Fixed Component: This is independent of the characteristics of the inputs and outputs. This part includes: Instruction Space, Space of simple variables, fixed size component variables, and constants variables. Variable Component: This consist of the space needed by component variables whose size is dependent on the particular problems instances(Inputs/Outputs) being solved, the space needed by referenced variables and the recursion stack space is one of the most prominent components. Also this included the data structure components like Linked list, heap, trees, graphs etc. Therefore the total space requirement of any algorithm 'A' can be provided as
  • 3. Space(A) = Fixed Components(A) + Variable Components(A) Among both fixed and variable component the variable part is important to be determined accurately, so that the actual space requirement can be identified for an algorithm 'A'. To identify the space complexity of any algorithm following steps can be followed: Determine the variables which are instantiated by some default values. Determine which instance characteristics should be used to measure the space requirement and this is will be problem specific. Generally the choices are limited to quantities related to the number and magnitudes of the inputs to and outputs from the algorithms. Sometimes more complex measures of the interrelationships among the data items can used.
  • 4. Example: Space Complexity Algorithm Sum(number , size) procedure will produce sum of all numbers provided in 'number' list { result=0.0; for count = 1 to size do will repeat from 1,2,3,4,....size times result= result + number[count]; return result; } In above example, when calculating the space complexity we will be looking for both fixed and variable components. here we have Fixed components as 'result','count' and 'size' variable there for total space required is three(3) words.
  • 5. Variable components is characterized as the value stored in 'size' variable (suppose value store in variable 'size 'is 'n'). because this will decide the size of 'number' list and will also drive the for loop. therefore if the space used by size is one word then the total space required by 'number' variable will be 'n'(value stored in variable 'size'). therefore the space complexity can be written as Space(Sum) = 3 + n;
  • 6. Time Complexity of an algorithm(basically when converted to program) is the amount of computer time it needs to run to completion. The time taken by a program is the sum of the compile time and the run/execution time .The compile time is independent of the instance(problem specific) characteristics. following factors effect the time complexity: Characteristics of compiler used to compile the program. Computer Machine on which the program is executed and physically clocked. Multiuser execution system. Number of program steps.
  • 7. Therefore the again the time complexity consist of two components fixed(factor 1 only) and variable/instance(factor 2,3 & 4), so for any algorithm 'A' it is provided as: Time(A) = Fixed Time(A) + Instance Time(A) Here the number of steps is the most prominent instance characteristics and The number of steps any program statement is assigned depends on the kind of statement like comments count as zero steps, an assignment statement which does not involve any calls to other algorithm is counted as one step, for iterative statements we consider the steps count only for the control part of the statement etc. Therefore to calculate total number program of program steps we use following procedure. For this we build a table in which we list the total number of steps contributed by each statement. This is often arrived at by first determining the number of steps per execution of the statement and the frequency of each statement executed. This procedure is explained using an example.
  • 8. Example: Time Complexity Statement Steps per execution Frequenc y Total Steps Algorithm Sum(number,size) 0 - 0 { 0 - 0 result=0.0; 1 1 1 for count = 1 to size do 1 size+ 1 size + 1 result= result + number[count]; 1 size size return result; 1 1 1 } 0 - 0 Total 2size + 3
  • 9. In above example if you analyze carefully frequency of "for count = 1 to size do" it is 'size +1' this is because the statement will be executed one time more die to condition check for false situation of condition provided in for statement. Now once the total steps are calculated they will resemble the instance characteristics in time complexity of algorithm. Also the repeated compile time of an algorithm will also be constant every time we compile the same set of instructions so we can consider this time as constant 'C'. Therefore the time complexity can be expressed as: Time(Sum) = C + (2size +3) So in this way both the Space complexity and Time complexity can be calculated. Combination of both complexity comprises the Performance analysis of any algorithm and can not be used independently. Both these complexities also helps in defining parameters on basis of which we optimize algorithms.
  • 10. Processing Speed In the computer world, frequency is often used to measure processing speed. For example, clock speed, measures how many cycles a processor can complete in one second. If a computer has a 3.2GHz processor, it can can complete 3,200,000,000 cycles per second. FLOPS, which is used to measure floating point performance, is also a frequency-based calculation (operations per second). Finally, computing speed may also be defined in MIPS, which measures instructions per second.
  • 11. Complexity of Algorithms The complexity of an algorithm M is the function f(n) which gives the running time and/or storage space requirement of the algorithm in terms of the size ‘n’ of the input data. Mostly, the storage space required by an algorithm is simply a multiple of the data size ‘n’. Complexity shall refer to the running time of the algorithm. The function f(n), gives the running time of an algorithm, depends not only on the size ‘n’ of the input data but also on the particular data. The complexity function f(n) for certain cases are: •Best Case: The minimum possible value of f(n) is called the best case. •Average Case : The expected value of f(n). Worst Case: The maximum value of f(n) for any key possible input.
  • 12. Asymptotic Notations The following notations are commonly use notations in performance analysis and used to characterize the complexity of an algorithm: •Big–OH (O) , •Big–OMEGA (Ω), •Big–THETA ( ) and •Little–OH (o)
  • 13. Big Oh Notation, Ο The notation Ο(n) is the formal way to express the upper bound of an algorithm's running time. It measures the worst case time complexity or the longest amount of time an algorithm can possibly take to complete. For example, for a function f(n) Ο(f(n)) = { g(n) : there exists c > 0 and n0 such that f(n) ≤ c.g(n) for all n > n0. }
  • 14. Omega Notation, Ω The notation Ω(n) is the formal way to express the lower bound of an algorithm's running time. It measures the best case time complexity or the best amount of time an algorithm can possibly take to complete. For example, for a function f(n) Ω(f(n)) ≥ { g(n) : there exists c > 0 and n0 such that g(n) ≤ c.f(n) for all n > n0. }
  • 15. Theta Notation, θ The notation θ(n) is the formal way to express both the lower bound and the upper bound of an algorithm's running time. It is represented as follows −θ(f(n)) = { g(n) if and only if g(n) = Ο(f(n)) and g(n) = Ω(f(n)) for all n > n0. }
  • 16. Amortized Analysis is used for algorithms where an occasional operation is very slow, but most of the other operations are faster. In Amortized Analysis, we analyze a sequence of operations and guarantee a worst case average time which is lower than the worst case time of a particular expensive operation. Aggregate Method The aggregate method is used to find the total cost. If we want to add a bunch of data, then we need to find the amortized cost by this formula. For a sequence of n operations, the cost is − Let us consider an example of a simple hash table insertions. How do we decide table size? There is a trade-off between space and time, if we make hash-table size big, search time becomes fast, but space required becomes high.
  • 17. The solution to this trade-off problem is to use Dynamic Table (or Arrays). The idea is to increase size of table whenever it becomes full. Following are the steps to follow when table becomes full. 1) Allocate memory for a larger table of size, typically twice the old table. 2) Copy the contents of old table to new table. 3) Free the old table. If the table has space available, we simply insert new item in available space.
  • 18. What is the time complexity of n insertions using the above scheme? If we use simple analysis, the worst case cost of an insertion is O(n). Therefore, worst case cost of n inserts is n * O(n) which is O(n2). This analysis gives an upper bound, but not a tight upper bound for n insertions as all insertions don’t take Θ(n) time. So using Amortized Analysis, we could prove that the Dynamic Table scheme has O(1) insertion time which is a great result used in hashing.
  • 19. Randomized Algorithms An algorithm that uses random numbers to decide what to do next anywhere in its logic is called Randomized Algorithm. Classification Randomized algorithms are classified in two categories. Las Vegas: These algorithms always produce correct or optimum result. Time complexity of these algorithms is based on a random value and time complexity is evaluated as expected value. Monte Carlo: Produce correct or optimum result with some probability. These algorithms have deterministic running time and it is generally easier to find out worst case time complexity. Applications Graph algorithms: Minimum spanning trees, shortest paths, minimum cuts. Counting and enumeration: Matrix permanent Counting combinatorial structures. Parallel and distributed computing: Deadlock avoidance distributed consensus. Probabilistic existence proofs: Show that a combinatorial object arises with non-zero probability among objects drawn from a suitable probability space.