SlideShare uma empresa Scribd logo
1 de 31
Algorithms and Data Structures
Algorithm analysis
By- Priyanka
Session 4 is about
 Seven Functions
 Analysis of algorithms
1. Constant Function
Simplest function:
f(n) = c (some fixed constant)
Value of n doesn’t matter.
Ex: adding two numbers, assigning variable,
comparing two numbers
2. Logarithm Function
f (n) = logb n
for some constant b > 1
This function is defined:
x = logbn if and only if bx = n
Value b is known as the base of the logarithm.
log n = log2 n.
Rules for algorithms
Given real numbers a , c > 0, and b , d > 1, we have
If b = 2, we either use log n, or lg n.
3. Linear function
f(n) = c n
Function arises when a single basic
operation is required for each of n
elements.
4. N- log- N function
f(n) = n logn
Grows faster than the linear function.
Slower than the quadratic function.
5. Quadratic function
f(n) = n2
For nested loops, where combined operations of
inner and outer loop gives n*n = n2.
6. Cubic Function & Other Polynomials
f(n) = n3
Comparatively less frequent
7. Exponential Function
f(n) = bn
b is a positive constant, called as the base.
n is the argument and called as the exponent.
Also called as exponent function.
Analysis of algorithm
Analysis of algorithm means:
Predicting the amount of resources
that the algorithm requires.
Analysis of algorithms
 Experimental Studies
 Primitive Operations
 Asymptotic Notation
Experimental Studies
Running time of implemented algorithm is calculated
by:
 Executing it on various test inputs.
 Recording the actual time spent in each
execution.
 Using the System.curent Time Millis () method.
Experimental Studies (cont.)
Steps :
1. Write a program implementing the algorithm.
2. Run the program with inputs of varying size and
composition.
3. Use a system call to get running time measure.
4. Plot the results.
5. Perform a statistical analysis.
Experimental Studies (cont.)
Limitations of Experimental analysis
 Need limited set of test inputs.
 Need same hardware and software
environments.
 have to fully implement and execute an
algorithm.
Primitive operations
Set of primitive operations:
1. Assigning a value to a variable.
2. Calling a method.
3. Performing an arithmetic operation (for example, adding two numbers).
4. Comparing two numbers.
5. Indexing into an array.
6. Following an object reference.
7. Returning from a method.
Example
Algorithm arrayMax(A, n)
# operations
currentMax ← A[0] 2
for i ← 1 to n − 1 do 2n
if A[i] > currentMax then 2(n − 1)
currentMax ← A[i] 2(n − 1)
{ increment counter i } 2(n − 1)
return currentMax 1
Total 8n − 2
Estimating Running Time
 Algorithm arrayMax executes 8n − 2 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 (8n − 2) ≤ T(n) ≤ b(8n − 2)
 Hence, the running time T(n) is bounded by two
linear functions.
Asymptotic Notation
 Uses mathematical notation for functions.
 Disregards constant factors.
 n refer to a chosen measure of the input “size”.
 Focus attention on the primary "big-picture"
aspects in a running time function.
Asymptotic Notation(cont.)
 Big-Oh Notation
 Big-Omega Notation
 Big-Theta Notation
Big – Oh Notation
Given functions are f(n) and g(n)
f(n) is O(g(n)) if there are positive constants
c>0 and n0 ≥1 such that
f(n) ≤ cg(n) for n ≥ n0
Big – Oh Notation (cont.)
Example: 2n + 10 is O(n)
2n + 10 ≤ cn
(c − 2) n ≥ 10
n ≥ 10/(c − 2)
Pick c = 3 and n0 = 10
Big – Oh Notation (cont.)
 Example: the function n2 is not O(n)
n2 ≤ cn
n ≤ c
The above inequality cannot be satisfied since c
must be a constant
Big – Omega Notation
Given functions are f(n) and g(n)
f(n) is Ω(g(n)) if there are positive constants
c>0 and n0 ≥1 such that
f(n) ≥ cg(n) for n ≥ n0
Big – Omega Notation(cont.)
Example : the function 5n2 is Ω(n2)
5n2 ≥ c n2
5n ≥ c n
c = 5 and n0 = 1
Big – Theta Notation
Given functions are f(n) and g(n)
f(n) is Θ(g(n)) if f(n) is O(g(n)) and f(n) is Ω(g(n)) ,
that is, there are real constants
c’> 0 and c’’ >0 and n0 ≥1 such that
c’ g(n) ≤ f(n) ≤ c’’ g(n) for n ≥ n0
Big – Theta Notation(cont.)
 Example : 3nlog n + 4n + 5logn is Θ(n log
n).
Justification:
3nlogn ≤ 3nlogn + 4n + 5logn ≤
(3+4+5)nlog n
for n ≥ 2
Thank You

Mais conteúdo relacionado

Mais procurados

Asymptotic Notation and Complexity
Asymptotic Notation and ComplexityAsymptotic Notation and Complexity
Asymptotic Notation and ComplexityRajandeep Gill
 
Python functions
Python functionsPython functions
Python functionsAliyamanasa
 
Anlysis and design of algorithms part 1
Anlysis and design of algorithms part 1Anlysis and design of algorithms part 1
Anlysis and design of algorithms part 1Deepak John
 
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
 
Binary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of AlgorithmsBinary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of AlgorithmsDrishti Bhalla
 
Strassen's matrix multiplication
Strassen's matrix multiplicationStrassen's matrix multiplication
Strassen's matrix multiplicationMegha V
 
Data Structure and Algorithms Hashing
Data Structure and Algorithms HashingData Structure and Algorithms Hashing
Data Structure and Algorithms HashingManishPrajapati78
 
Sparse matrix and its representation data structure
Sparse matrix and its representation data structureSparse matrix and its representation data structure
Sparse matrix and its representation data structureVardhil Patel
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notationsEhtisham Ali
 
how to calclute time complexity of algortihm
how to calclute time complexity of algortihmhow to calclute time complexity of algortihm
how to calclute time complexity of algortihmSajid Marwat
 
Algorithm And analysis Lecture 03& 04-time complexity.
 Algorithm And analysis Lecture 03& 04-time complexity. Algorithm And analysis Lecture 03& 04-time complexity.
Algorithm And analysis Lecture 03& 04-time complexity.Tariq Khan
 
Data Structures- Part5 recursion
Data Structures- Part5 recursionData Structures- Part5 recursion
Data Structures- Part5 recursionAbdullah Al-hazmy
 

Mais procurados (20)

Asymptotic Notation and Complexity
Asymptotic Notation and ComplexityAsymptotic Notation and Complexity
Asymptotic Notation and Complexity
 
Python functions
Python functionsPython functions
Python functions
 
Anlysis and design of algorithms part 1
Anlysis and design of algorithms part 1Anlysis and design of algorithms part 1
Anlysis and design of algorithms part 1
 
Bottom up parser
Bottom up parserBottom up parser
Bottom up parser
 
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
 
Binary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of AlgorithmsBinary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of Algorithms
 
Strassen's matrix multiplication
Strassen's matrix multiplicationStrassen's matrix multiplication
Strassen's matrix multiplication
 
Python programming : Files
Python programming : FilesPython programming : Files
Python programming : Files
 
Data Structure and Algorithms Hashing
Data Structure and Algorithms HashingData Structure and Algorithms Hashing
Data Structure and Algorithms Hashing
 
Double ended queue
Double ended queueDouble ended queue
Double ended queue
 
Sparse matrix and its representation data structure
Sparse matrix and its representation data structureSparse matrix and its representation data structure
Sparse matrix and its representation data structure
 
Infix to postfix conversion
Infix to postfix conversionInfix to postfix conversion
Infix to postfix conversion
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
 
Computational Complexity
Computational ComplexityComputational Complexity
Computational Complexity
 
how to calclute time complexity of algortihm
how to calclute time complexity of algortihmhow to calclute time complexity of algortihm
how to calclute time complexity of algortihm
 
stack & queue
stack & queuestack & queue
stack & queue
 
Analysis of algorithm
Analysis of algorithmAnalysis of algorithm
Analysis of algorithm
 
Algorithm And analysis Lecture 03& 04-time complexity.
 Algorithm And analysis Lecture 03& 04-time complexity. Algorithm And analysis Lecture 03& 04-time complexity.
Algorithm And analysis Lecture 03& 04-time complexity.
 
Linear Search Presentation
Linear Search PresentationLinear Search Presentation
Linear Search Presentation
 
Data Structures- Part5 recursion
Data Structures- Part5 recursionData Structures- Part5 recursion
Data Structures- Part5 recursion
 

Semelhante a Algorithm analysis basics - Seven Functions/Big-Oh/Omega/Theta

Data Structures- Part2 analysis tools
Data Structures- Part2 analysis toolsData Structures- Part2 analysis tools
Data Structures- Part2 analysis toolsAbdullah Al-hazmy
 
Data Structures and Algorithms Lecture 2: Analysis of Algorithms, Asymptotic ...
Data Structures and Algorithms Lecture 2: Analysis of Algorithms, Asymptotic ...Data Structures and Algorithms Lecture 2: Analysis of Algorithms, Asymptotic ...
Data Structures and Algorithms Lecture 2: Analysis of Algorithms, Asymptotic ...TechVision8
 
Data Structure & Algorithms - Mathematical
Data Structure & Algorithms - MathematicalData Structure & Algorithms - Mathematical
Data Structure & Algorithms - Mathematicalbabuk110
 
DS Unit-1.pptx very easy to understand..
DS Unit-1.pptx very easy to understand..DS Unit-1.pptx very easy to understand..
DS Unit-1.pptx very easy to understand..KarthikeyaLanka1
 
Algorithm Analysis
Algorithm AnalysisAlgorithm Analysis
Algorithm AnalysisMegha V
 
Algorithm chapter 2
Algorithm chapter 2Algorithm chapter 2
Algorithm chapter 2chidabdu
 
lecture 1
lecture 1lecture 1
lecture 1sajinsc
 
Algorithms required for data structures(basics like Arrays, Stacks ,Linked Li...
Algorithms required for data structures(basics like Arrays, Stacks ,Linked Li...Algorithms required for data structures(basics like Arrays, Stacks ,Linked Li...
Algorithms required for data structures(basics like Arrays, Stacks ,Linked Li...DebiPrasadSen
 
Design and Analysis of Algorithms Lecture Notes
Design and Analysis of Algorithms Lecture NotesDesign and Analysis of Algorithms Lecture Notes
Design and Analysis of Algorithms Lecture NotesSreedhar Chowdam
 
Lec03 04-time complexity
Lec03 04-time complexityLec03 04-time complexity
Lec03 04-time complexityAbbas Ali
 
Daa unit 6_efficiency of algorithms
Daa unit 6_efficiency of algorithmsDaa unit 6_efficiency of algorithms
Daa unit 6_efficiency of algorithmssnehajiyani
 
04. Growth_Rate_AND_Asymptotic Notations_.pptx
04. Growth_Rate_AND_Asymptotic Notations_.pptx04. Growth_Rate_AND_Asymptotic Notations_.pptx
04. Growth_Rate_AND_Asymptotic Notations_.pptxarslanzaheer14
 
Lecture 2 data structures and algorithms
Lecture 2 data structures and algorithmsLecture 2 data structures and algorithms
Lecture 2 data structures and algorithmsAakash deep Singhal
 
Data Structures and Algorithms - Lec 02.pdf
Data Structures and Algorithms - Lec 02.pdfData Structures and Algorithms - Lec 02.pdf
Data Structures and Algorithms - Lec 02.pdfRameshaFernando2
 
ALGORITHM-ANALYSIS.ppt
ALGORITHM-ANALYSIS.pptALGORITHM-ANALYSIS.ppt
ALGORITHM-ANALYSIS.pptsapnaverma97
 

Semelhante a Algorithm analysis basics - Seven Functions/Big-Oh/Omega/Theta (20)

3 analysis.gtm
3 analysis.gtm3 analysis.gtm
3 analysis.gtm
 
Data Structures- Part2 analysis tools
Data Structures- Part2 analysis toolsData Structures- Part2 analysis tools
Data Structures- Part2 analysis tools
 
Lec1
Lec1Lec1
Lec1
 
Data Structures and Algorithms Lecture 2: Analysis of Algorithms, Asymptotic ...
Data Structures and Algorithms Lecture 2: Analysis of Algorithms, Asymptotic ...Data Structures and Algorithms Lecture 2: Analysis of Algorithms, Asymptotic ...
Data Structures and Algorithms Lecture 2: Analysis of Algorithms, Asymptotic ...
 
Data Structure & Algorithms - Mathematical
Data Structure & Algorithms - MathematicalData Structure & Algorithms - Mathematical
Data Structure & Algorithms - Mathematical
 
DS Unit-1.pptx very easy to understand..
DS Unit-1.pptx very easy to understand..DS Unit-1.pptx very easy to understand..
DS Unit-1.pptx very easy to understand..
 
Algorithm Analysis
Algorithm AnalysisAlgorithm Analysis
Algorithm Analysis
 
AlgorithmAnalysis2.ppt
AlgorithmAnalysis2.pptAlgorithmAnalysis2.ppt
AlgorithmAnalysis2.ppt
 
Algorithm chapter 2
Algorithm chapter 2Algorithm chapter 2
Algorithm chapter 2
 
lecture 1
lecture 1lecture 1
lecture 1
 
Algorithms required for data structures(basics like Arrays, Stacks ,Linked Li...
Algorithms required for data structures(basics like Arrays, Stacks ,Linked Li...Algorithms required for data structures(basics like Arrays, Stacks ,Linked Li...
Algorithms required for data structures(basics like Arrays, Stacks ,Linked Li...
 
Design and Analysis of Algorithms Lecture Notes
Design and Analysis of Algorithms Lecture NotesDesign and Analysis of Algorithms Lecture Notes
Design and Analysis of Algorithms Lecture Notes
 
Lec03 04-time complexity
Lec03 04-time complexityLec03 04-time complexity
Lec03 04-time complexity
 
Daa unit 6_efficiency of algorithms
Daa unit 6_efficiency of algorithmsDaa unit 6_efficiency of algorithms
Daa unit 6_efficiency of algorithms
 
Time complexity.ppt
Time complexity.pptTime complexity.ppt
Time complexity.ppt
 
Analysis of Algorithum
Analysis of AlgorithumAnalysis of Algorithum
Analysis of Algorithum
 
04. Growth_Rate_AND_Asymptotic Notations_.pptx
04. Growth_Rate_AND_Asymptotic Notations_.pptx04. Growth_Rate_AND_Asymptotic Notations_.pptx
04. Growth_Rate_AND_Asymptotic Notations_.pptx
 
Lecture 2 data structures and algorithms
Lecture 2 data structures and algorithmsLecture 2 data structures and algorithms
Lecture 2 data structures and algorithms
 
Data Structures and Algorithms - Lec 02.pdf
Data Structures and Algorithms - Lec 02.pdfData Structures and Algorithms - Lec 02.pdf
Data Structures and Algorithms - Lec 02.pdf
 
ALGORITHM-ANALYSIS.ppt
ALGORITHM-ANALYSIS.pptALGORITHM-ANALYSIS.ppt
ALGORITHM-ANALYSIS.ppt
 

Mais de Priyanka Rana

Insertion & Selection Sort - using Priority Queues
Insertion & Selection Sort - using Priority QueuesInsertion & Selection Sort - using Priority Queues
Insertion & Selection Sort - using Priority QueuesPriyanka Rana
 
Content package - Mobile computing
Content package - Mobile computingContent package - Mobile computing
Content package - Mobile computingPriyanka Rana
 
Scrum retrospective
Scrum retrospective Scrum retrospective
Scrum retrospective Priyanka Rana
 
Convergent divergent thinking & wireframeprototyping
Convergent divergent thinking & wireframeprototypingConvergent divergent thinking & wireframeprototyping
Convergent divergent thinking & wireframeprototypingPriyanka Rana
 
Sketching&storyboarding
Sketching&storyboardingSketching&storyboarding
Sketching&storyboardingPriyanka Rana
 
Building better prototype
Building better prototypeBuilding better prototype
Building better prototypePriyanka Rana
 
Mobile presence & location based marketing
Mobile presence & location based marketingMobile presence & location based marketing
Mobile presence & location based marketingPriyanka Rana
 
User friendliness of website
User friendliness of websiteUser friendliness of website
User friendliness of websitePriyanka Rana
 
E-commerce Marketing & advertising
E-commerce Marketing & advertisingE-commerce Marketing & advertising
E-commerce Marketing & advertisingPriyanka Rana
 
E commerce business proposal
E commerce business proposalE commerce business proposal
E commerce business proposalPriyanka Rana
 
E-strategic Management-1
E-strategic Management-1E-strategic Management-1
E-strategic Management-1Priyanka Rana
 
Heaps & Adaptable priority Queues
Heaps & Adaptable priority QueuesHeaps & Adaptable priority Queues
Heaps & Adaptable priority QueuesPriyanka Rana
 
Trees - Non Linear Data Structure
Trees - Non Linear Data StructureTrees - Non Linear Data Structure
Trees - Non Linear Data StructurePriyanka Rana
 

Mais de Priyanka Rana (18)

Insertion & Selection Sort - using Priority Queues
Insertion & Selection Sort - using Priority QueuesInsertion & Selection Sort - using Priority Queues
Insertion & Selection Sort - using Priority Queues
 
Scrum values
Scrum valuesScrum values
Scrum values
 
Usability testing
Usability testing  Usability testing
Usability testing
 
Content package - Mobile computing
Content package - Mobile computingContent package - Mobile computing
Content package - Mobile computing
 
Scrum retrospective
Scrum retrospective Scrum retrospective
Scrum retrospective
 
Convergent divergent thinking & wireframeprototyping
Convergent divergent thinking & wireframeprototypingConvergent divergent thinking & wireframeprototyping
Convergent divergent thinking & wireframeprototyping
 
Sketching&storyboarding
Sketching&storyboardingSketching&storyboarding
Sketching&storyboarding
 
Building better prototype
Building better prototypeBuilding better prototype
Building better prototype
 
Mobile presence & location based marketing
Mobile presence & location based marketingMobile presence & location based marketing
Mobile presence & location based marketing
 
User friendliness of website
User friendliness of websiteUser friendliness of website
User friendliness of website
 
E-commerce Marketing & advertising
E-commerce Marketing & advertisingE-commerce Marketing & advertising
E-commerce Marketing & advertising
 
E commerce business proposal
E commerce business proposalE commerce business proposal
E commerce business proposal
 
E-strategic Management-1
E-strategic Management-1E-strategic Management-1
E-strategic Management-1
 
Maps&hash tables
Maps&hash tablesMaps&hash tables
Maps&hash tables
 
Heaps & Adaptable priority Queues
Heaps & Adaptable priority QueuesHeaps & Adaptable priority Queues
Heaps & Adaptable priority Queues
 
Priority queues
Priority queuesPriority queues
Priority queues
 
Trees - Non Linear Data Structure
Trees - Non Linear Data StructureTrees - Non Linear Data Structure
Trees - Non Linear Data Structure
 
Linked list
Linked listLinked list
Linked list
 

Último

Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 

Último (20)

Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 

Algorithm analysis basics - Seven Functions/Big-Oh/Omega/Theta

  • 1. Algorithms and Data Structures Algorithm analysis By- Priyanka
  • 2. Session 4 is about  Seven Functions  Analysis of algorithms
  • 3. 1. Constant Function Simplest function: f(n) = c (some fixed constant) Value of n doesn’t matter. Ex: adding two numbers, assigning variable, comparing two numbers
  • 4. 2. Logarithm Function f (n) = logb n for some constant b > 1 This function is defined: x = logbn if and only if bx = n Value b is known as the base of the logarithm. log n = log2 n.
  • 5. Rules for algorithms Given real numbers a , c > 0, and b , d > 1, we have If b = 2, we either use log n, or lg n.
  • 6. 3. Linear function f(n) = c n Function arises when a single basic operation is required for each of n elements.
  • 7. 4. N- log- N function f(n) = n logn Grows faster than the linear function. Slower than the quadratic function.
  • 8. 5. Quadratic function f(n) = n2 For nested loops, where combined operations of inner and outer loop gives n*n = n2.
  • 9. 6. Cubic Function & Other Polynomials f(n) = n3 Comparatively less frequent
  • 10. 7. Exponential Function f(n) = bn b is a positive constant, called as the base. n is the argument and called as the exponent. Also called as exponent function.
  • 11. Analysis of algorithm Analysis of algorithm means: Predicting the amount of resources that the algorithm requires.
  • 12.
  • 13. Analysis of algorithms  Experimental Studies  Primitive Operations  Asymptotic Notation
  • 14. Experimental Studies Running time of implemented algorithm is calculated by:  Executing it on various test inputs.  Recording the actual time spent in each execution.  Using the System.curent Time Millis () method.
  • 15. Experimental Studies (cont.) Steps : 1. Write a program implementing the algorithm. 2. Run the program with inputs of varying size and composition. 3. Use a system call to get running time measure. 4. Plot the results. 5. Perform a statistical analysis.
  • 17. Limitations of Experimental analysis  Need limited set of test inputs.  Need same hardware and software environments.  have to fully implement and execute an algorithm.
  • 18. Primitive operations Set of primitive operations: 1. Assigning a value to a variable. 2. Calling a method. 3. Performing an arithmetic operation (for example, adding two numbers). 4. Comparing two numbers. 5. Indexing into an array. 6. Following an object reference. 7. Returning from a method.
  • 19. Example Algorithm arrayMax(A, n) # operations currentMax ← A[0] 2 for i ← 1 to n − 1 do 2n if A[i] > currentMax then 2(n − 1) currentMax ← A[i] 2(n − 1) { increment counter i } 2(n − 1) return currentMax 1 Total 8n − 2
  • 20. Estimating Running Time  Algorithm arrayMax executes 8n − 2 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 (8n − 2) ≤ T(n) ≤ b(8n − 2)  Hence, the running time T(n) is bounded by two linear functions.
  • 21. Asymptotic Notation  Uses mathematical notation for functions.  Disregards constant factors.  n refer to a chosen measure of the input “size”.  Focus attention on the primary "big-picture" aspects in a running time function.
  • 22. Asymptotic Notation(cont.)  Big-Oh Notation  Big-Omega Notation  Big-Theta Notation
  • 23. Big – Oh Notation Given functions are f(n) and g(n) f(n) is O(g(n)) if there are positive constants c>0 and n0 ≥1 such that f(n) ≤ cg(n) for n ≥ n0
  • 24. Big – Oh Notation (cont.) Example: 2n + 10 is O(n) 2n + 10 ≤ cn (c − 2) n ≥ 10 n ≥ 10/(c − 2) Pick c = 3 and n0 = 10
  • 25. Big – Oh Notation (cont.)  Example: the function n2 is not O(n) n2 ≤ cn n ≤ c The above inequality cannot be satisfied since c must be a constant
  • 26.
  • 27. Big – Omega Notation Given functions are f(n) and g(n) f(n) is Ω(g(n)) if there are positive constants c>0 and n0 ≥1 such that f(n) ≥ cg(n) for n ≥ n0
  • 28. Big – Omega Notation(cont.) Example : the function 5n2 is Ω(n2) 5n2 ≥ c n2 5n ≥ c n c = 5 and n0 = 1
  • 29. Big – Theta Notation Given functions are f(n) and g(n) f(n) is Θ(g(n)) if f(n) is O(g(n)) and f(n) is Ω(g(n)) , that is, there are real constants c’> 0 and c’’ >0 and n0 ≥1 such that c’ g(n) ≤ f(n) ≤ c’’ g(n) for n ≥ n0
  • 30. Big – Theta Notation(cont.)  Example : 3nlog n + 4n + 5logn is Θ(n log n). Justification: 3nlogn ≤ 3nlogn + 4n + 5logn ≤ (3+4+5)nlog n for n ≥ 2

Notas do Editor

  1. <number>
  2. <number>