SlideShare a Scribd company logo
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.
Algorithm analysis basics - Seven Functions/Big-Oh/Omega/Theta
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
Algorithm analysis basics - Seven Functions/Big-Oh/Omega/Theta
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
Ad

More Related Content

What's hot (20)

Deadlock dbms
Deadlock dbmsDeadlock dbms
Deadlock dbms
Vardhil Patel
 
Directory structure
Directory structureDirectory structure
Directory structure
sangrampatil81
 
Lexical Analysis - Compiler design
Lexical Analysis - Compiler design Lexical Analysis - Compiler design
Lexical Analysis - Compiler design
Aman Sharma
 
Knowledge representation
Knowledge representationKnowledge representation
Knowledge representation
Amit Kumar Rathi
 
Loop optimization
Loop optimizationLoop optimization
Loop optimization
Vivek Gandhi
 
Semaphore
SemaphoreSemaphore
Semaphore
Arafat Hossan
 
Algorithmic problem solving
Algorithmic problem solvingAlgorithmic problem solving
Algorithmic problem solving
Prabhakaran V M
 
Interface in java
Interface in javaInterface in java
Interface in java
PhD Research Scholar
 
Java interfaces
Java interfacesJava interfaces
Java interfaces
Raja Sekhar
 
Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting Algorithms
Pranay Neema
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OS
vampugani
 
backpropagation in neural networks
backpropagation in neural networksbackpropagation in neural networks
backpropagation in neural networks
Akash Goel
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
Nikhil Sharma
 
Design and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptxDesign and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptx
Syed Zaid Irshad
 
Bruteforce algorithm
Bruteforce algorithmBruteforce algorithm
Bruteforce algorithm
Rezwan Siam
 
MULTI THREADING IN JAVA
MULTI THREADING IN JAVAMULTI THREADING IN JAVA
MULTI THREADING IN JAVA
VINOTH R
 
Forms of learning in ai
Forms of learning in aiForms of learning in ai
Forms of learning in ai
Robert Antony
 
Remote backup system
Remote backup systemRemote backup system
Remote backup system
DipendraMahato3
 
process and thread.pptx
process and thread.pptxprocess and thread.pptx
process and thread.pptx
HamzaxTv
 
Genetic programming
Genetic programmingGenetic programming
Genetic programming
Meghna Singh
 
Lexical Analysis - Compiler design
Lexical Analysis - Compiler design Lexical Analysis - Compiler design
Lexical Analysis - Compiler design
Aman Sharma
 
Algorithmic problem solving
Algorithmic problem solvingAlgorithmic problem solving
Algorithmic problem solving
Prabhakaran V M
 
Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting Algorithms
Pranay Neema
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OS
vampugani
 
backpropagation in neural networks
backpropagation in neural networksbackpropagation in neural networks
backpropagation in neural networks
Akash Goel
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
Nikhil Sharma
 
Design and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptxDesign and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptx
Syed Zaid Irshad
 
Bruteforce algorithm
Bruteforce algorithmBruteforce algorithm
Bruteforce algorithm
Rezwan Siam
 
MULTI THREADING IN JAVA
MULTI THREADING IN JAVAMULTI THREADING IN JAVA
MULTI THREADING IN JAVA
VINOTH R
 
Forms of learning in ai
Forms of learning in aiForms of learning in ai
Forms of learning in ai
Robert Antony
 
process and thread.pptx
process and thread.pptxprocess and thread.pptx
process and thread.pptx
HamzaxTv
 
Genetic programming
Genetic programmingGenetic programming
Genetic programming
Meghna Singh
 

Similar to Algorithm analysis basics - Seven Functions/Big-Oh/Omega/Theta (20)

3 analysis.gtm
3 analysis.gtm3 analysis.gtm
3 analysis.gtm
Natarajan Angappan
 
introduction to algorithm for beginneer1
introduction to algorithm for beginneer1introduction to algorithm for beginneer1
introduction to algorithm for beginneer1
ranjankumarbehera14
 
Data Structures- Part2 analysis tools
Data Structures- Part2 analysis toolsData Structures- Part2 analysis tools
Data Structures- Part2 analysis tools
Abdullah Al-hazmy
 
ESINF03-AlgAnalis.pdfESINF03-AlgAnalis.pdf
ESINF03-AlgAnalis.pdfESINF03-AlgAnalis.pdfESINF03-AlgAnalis.pdfESINF03-AlgAnalis.pdf
ESINF03-AlgAnalis.pdfESINF03-AlgAnalis.pdf
LusArajo20
 
Big-O notations, Algorithm and complexity analaysis
Big-O notations, Algorithm and complexity analaysisBig-O notations, Algorithm and complexity analaysis
Big-O notations, Algorithm and complexity analaysis
drsomya2019
 
Presentation_23953_Content_Document_20240906040454PM.pptx
Presentation_23953_Content_Document_20240906040454PM.pptxPresentation_23953_Content_Document_20240906040454PM.pptx
Presentation_23953_Content_Document_20240906040454PM.pptx
rameshmanoj733
 
Lec1
Lec1Lec1
Lec1
Nikhil Chilwant
 
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
 
Module-1.pptxbdjdhcdbejdjhdbchchchchchjcjcjc
Module-1.pptxbdjdhcdbejdjhdbchchchchchjcjcjcModule-1.pptxbdjdhcdbejdjhdbchchchchchjcjcjc
Module-1.pptxbdjdhcdbejdjhdbchchchchchjcjcjc
shashashashashank
 
Data Structures and Agorithm: DS 22 Analysis of Algorithm.pptx
Data Structures and Agorithm: DS 22 Analysis of Algorithm.pptxData Structures and Agorithm: DS 22 Analysis of Algorithm.pptx
Data Structures and Agorithm: DS 22 Analysis of Algorithm.pptx
RashidFaridChishti
 
Data Structure & Algorithms - Mathematical
Data Structure & Algorithms - MathematicalData Structure & Algorithms - Mathematical
Data Structure & Algorithms - Mathematical
babuk110
 
1ST_UNIT_DAdefewfrewfgrwefrAdfdgfdsgevedr (2).pdf
1ST_UNIT_DAdefewfrewfgrwefrAdfdgfdsgevedr (2).pdf1ST_UNIT_DAdefewfrewfgrwefrAdfdgfdsgevedr (2).pdf
1ST_UNIT_DAdefewfrewfgrwefrAdfdgfdsgevedr (2).pdf
ravisikka1
 
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 Analysis
Megha V
 
AlgorithmAnalysis2.ppt
AlgorithmAnalysis2.pptAlgorithmAnalysis2.ppt
AlgorithmAnalysis2.ppt
REMEGIUSPRAVEENSAHAY
 
BCS401 ADA First IA Test Question Bank.pdf
BCS401 ADA First IA Test Question Bank.pdfBCS401 ADA First IA Test Question Bank.pdf
BCS401 ADA First IA Test Question Bank.pdf
VENKATESHBHAT25
 
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
 
Algorithm chapter 2
Algorithm chapter 2Algorithm chapter 2
Algorithm chapter 2
chidabdu
 
lecture 1
lecture 1lecture 1
lecture 1
sajinsc
 
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
 
introduction to algorithm for beginneer1
introduction to algorithm for beginneer1introduction to algorithm for beginneer1
introduction to algorithm for beginneer1
ranjankumarbehera14
 
Data Structures- Part2 analysis tools
Data Structures- Part2 analysis toolsData Structures- Part2 analysis tools
Data Structures- Part2 analysis tools
Abdullah Al-hazmy
 
ESINF03-AlgAnalis.pdfESINF03-AlgAnalis.pdf
ESINF03-AlgAnalis.pdfESINF03-AlgAnalis.pdfESINF03-AlgAnalis.pdfESINF03-AlgAnalis.pdf
ESINF03-AlgAnalis.pdfESINF03-AlgAnalis.pdf
LusArajo20
 
Big-O notations, Algorithm and complexity analaysis
Big-O notations, Algorithm and complexity analaysisBig-O notations, Algorithm and complexity analaysis
Big-O notations, Algorithm and complexity analaysis
drsomya2019
 
Presentation_23953_Content_Document_20240906040454PM.pptx
Presentation_23953_Content_Document_20240906040454PM.pptxPresentation_23953_Content_Document_20240906040454PM.pptx
Presentation_23953_Content_Document_20240906040454PM.pptx
rameshmanoj733
 
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
 
Module-1.pptxbdjdhcdbejdjhdbchchchchchjcjcjc
Module-1.pptxbdjdhcdbejdjhdbchchchchchjcjcjcModule-1.pptxbdjdhcdbejdjhdbchchchchchjcjcjc
Module-1.pptxbdjdhcdbejdjhdbchchchchchjcjcjc
shashashashashank
 
Data Structures and Agorithm: DS 22 Analysis of Algorithm.pptx
Data Structures and Agorithm: DS 22 Analysis of Algorithm.pptxData Structures and Agorithm: DS 22 Analysis of Algorithm.pptx
Data Structures and Agorithm: DS 22 Analysis of Algorithm.pptx
RashidFaridChishti
 
Data Structure & Algorithms - Mathematical
Data Structure & Algorithms - MathematicalData Structure & Algorithms - Mathematical
Data Structure & Algorithms - Mathematical
babuk110
 
1ST_UNIT_DAdefewfrewfgrwefrAdfdgfdsgevedr (2).pdf
1ST_UNIT_DAdefewfrewfgrwefrAdfdgfdsgevedr (2).pdf1ST_UNIT_DAdefewfrewfgrwefrAdfdgfdsgevedr (2).pdf
1ST_UNIT_DAdefewfrewfgrwefrAdfdgfdsgevedr (2).pdf
ravisikka1
 
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 Analysis
Megha V
 
BCS401 ADA First IA Test Question Bank.pdf
BCS401 ADA First IA Test Question Bank.pdfBCS401 ADA First IA Test Question Bank.pdf
BCS401 ADA First IA Test Question Bank.pdf
VENKATESHBHAT25
 
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
 
Algorithm chapter 2
Algorithm chapter 2Algorithm chapter 2
Algorithm chapter 2
chidabdu
 
lecture 1
lecture 1lecture 1
lecture 1
sajinsc
 
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
 
Ad

More from Priyanka Rana (19)

Insertion & Selection Sort - using Priority Queues
Insertion & Selection Sort - using Priority QueuesInsertion & Selection Sort - using Priority Queues
Insertion & Selection Sort - using Priority Queues
Priyanka Rana
 
Scrum values
Scrum valuesScrum values
Scrum values
Priyanka Rana
 
Usability testing
Usability testing  Usability testing
Usability testing
Priyanka Rana
 
Content package - Mobile computing
Content package - Mobile computingContent package - Mobile computing
Content package - Mobile computing
Priyanka 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 & wireframeprototyping
Priyanka Rana
 
Sketching&storyboarding
Sketching&storyboardingSketching&storyboarding
Sketching&storyboarding
Priyanka Rana
 
Building better prototype
Building better prototypeBuilding better prototype
Building better prototype
Priyanka Rana
 
Mobile presence & location based marketing
Mobile presence & location based marketingMobile presence & location based marketing
Mobile presence & location based marketing
Priyanka Rana
 
User friendliness of website
User friendliness of websiteUser friendliness of website
User friendliness of website
Priyanka Rana
 
E-commerce Marketing & advertising
E-commerce Marketing & advertisingE-commerce Marketing & advertising
E-commerce Marketing & advertising
Priyanka Rana
 
E commerce business proposal
E commerce business proposalE commerce business proposal
E commerce business proposal
Priyanka Rana
 
E-strategic Management-1
E-strategic Management-1E-strategic Management-1
E-strategic Management-1
Priyanka Rana
 
Maps&hash tables
Maps&hash tablesMaps&hash tables
Maps&hash tables
Priyanka Rana
 
Heaps & Adaptable priority Queues
Heaps & Adaptable priority QueuesHeaps & Adaptable priority Queues
Heaps & Adaptable priority Queues
Priyanka Rana
 
Priority queues
Priority queuesPriority queues
Priority queues
Priyanka Rana
 
Trees - Non Linear Data Structure
Trees - Non Linear Data StructureTrees - Non Linear Data Structure
Trees - Non Linear Data Structure
Priyanka Rana
 
Recursion - Algorithms and Data Structures
Recursion - Algorithms and Data StructuresRecursion - Algorithms and Data Structures
Recursion - Algorithms and Data Structures
Priyanka Rana
 
Linked list
Linked listLinked list
Linked list
Priyanka Rana
 
Insertion & Selection Sort - using Priority Queues
Insertion & Selection Sort - using Priority QueuesInsertion & Selection Sort - using Priority Queues
Insertion & Selection Sort - using Priority Queues
Priyanka Rana
 
Content package - Mobile computing
Content package - Mobile computingContent package - Mobile computing
Content package - Mobile computing
Priyanka 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 & wireframeprototyping
Priyanka Rana
 
Sketching&storyboarding
Sketching&storyboardingSketching&storyboarding
Sketching&storyboarding
Priyanka Rana
 
Building better prototype
Building better prototypeBuilding better prototype
Building better prototype
Priyanka Rana
 
Mobile presence & location based marketing
Mobile presence & location based marketingMobile presence & location based marketing
Mobile presence & location based marketing
Priyanka Rana
 
User friendliness of website
User friendliness of websiteUser friendliness of website
User friendliness of website
Priyanka Rana
 
E-commerce Marketing & advertising
E-commerce Marketing & advertisingE-commerce Marketing & advertising
E-commerce Marketing & advertising
Priyanka Rana
 
E commerce business proposal
E commerce business proposalE commerce business proposal
E commerce business proposal
Priyanka Rana
 
E-strategic Management-1
E-strategic Management-1E-strategic Management-1
E-strategic Management-1
Priyanka Rana
 
Heaps & Adaptable priority Queues
Heaps & Adaptable priority QueuesHeaps & Adaptable priority Queues
Heaps & Adaptable priority Queues
Priyanka Rana
 
Trees - Non Linear Data Structure
Trees - Non Linear Data StructureTrees - Non Linear Data Structure
Trees - Non Linear Data Structure
Priyanka Rana
 
Recursion - Algorithms and Data Structures
Recursion - Algorithms and Data StructuresRecursion - Algorithms and Data Structures
Recursion - Algorithms and Data Structures
Priyanka Rana
 
Ad

Recently uploaded (20)

Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
Canadian book publishing: Insights from the latest salary survey - Tech Forum...
Canadian book publishing: Insights from the latest salary survey - Tech Forum...Canadian book publishing: Insights from the latest salary survey - Tech Forum...
Canadian book publishing: Insights from the latest salary survey - Tech Forum...
BookNet Canada
 
MINDCTI revenue release Quarter 1 2025 PR
MINDCTI revenue release Quarter 1 2025 PRMINDCTI revenue release Quarter 1 2025 PR
MINDCTI revenue release Quarter 1 2025 PR
MIND CTI
 
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make .pptx
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make   .pptxWebinar - Top 5 Backup Mistakes MSPs and Businesses Make   .pptx
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make .pptx
MSP360
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
TrsLabs - AI Agents for All - Chatbots to Multi-Agents Systems
TrsLabs - AI Agents for All - Chatbots to Multi-Agents SystemsTrsLabs - AI Agents for All - Chatbots to Multi-Agents Systems
TrsLabs - AI Agents for All - Chatbots to Multi-Agents Systems
Trs Labs
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Build 3D Animated Safety Induction - Tech EHS
Build 3D Animated Safety Induction - Tech EHSBuild 3D Animated Safety Induction - Tech EHS
Build 3D Animated Safety Induction - Tech EHS
TECH EHS Solution
 
Transcript: Canadian book publishing: Insights from the latest salary survey ...
Transcript: Canadian book publishing: Insights from the latest salary survey ...Transcript: Canadian book publishing: Insights from the latest salary survey ...
Transcript: Canadian book publishing: Insights from the latest salary survey ...
BookNet Canada
 
Web and Graphics Designing Training in Rajpura
Web and Graphics Designing Training in RajpuraWeb and Graphics Designing Training in Rajpura
Web and Graphics Designing Training in Rajpura
Erginous Technology
 
Vibe Coding_ Develop a web application using AI (1).pdf
Vibe Coding_ Develop a web application using AI (1).pdfVibe Coding_ Develop a web application using AI (1).pdf
Vibe Coding_ Develop a web application using AI (1).pdf
Baiju Muthukadan
 
AsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API DesignAsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API Design
leonid54
 
TrsLabs Consultants - DeFi, WEb3, Token Listing
TrsLabs Consultants - DeFi, WEb3, Token ListingTrsLabs Consultants - DeFi, WEb3, Token Listing
TrsLabs Consultants - DeFi, WEb3, Token Listing
Trs Labs
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptxReimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
John Moore
 
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent LasterAI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
All Things Open
 
Unlocking Generative AI in your Web Apps
Unlocking Generative AI in your Web AppsUnlocking Generative AI in your Web Apps
Unlocking Generative AI in your Web Apps
Maximiliano Firtman
 
TrsLabs - Leverage the Power of UPI Payments
TrsLabs - Leverage the Power of UPI PaymentsTrsLabs - Leverage the Power of UPI Payments
TrsLabs - Leverage the Power of UPI Payments
Trs Labs
 
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Markus Eisele
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
Canadian book publishing: Insights from the latest salary survey - Tech Forum...
Canadian book publishing: Insights from the latest salary survey - Tech Forum...Canadian book publishing: Insights from the latest salary survey - Tech Forum...
Canadian book publishing: Insights from the latest salary survey - Tech Forum...
BookNet Canada
 
MINDCTI revenue release Quarter 1 2025 PR
MINDCTI revenue release Quarter 1 2025 PRMINDCTI revenue release Quarter 1 2025 PR
MINDCTI revenue release Quarter 1 2025 PR
MIND CTI
 
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make .pptx
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make   .pptxWebinar - Top 5 Backup Mistakes MSPs and Businesses Make   .pptx
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make .pptx
MSP360
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
TrsLabs - AI Agents for All - Chatbots to Multi-Agents Systems
TrsLabs - AI Agents for All - Chatbots to Multi-Agents SystemsTrsLabs - AI Agents for All - Chatbots to Multi-Agents Systems
TrsLabs - AI Agents for All - Chatbots to Multi-Agents Systems
Trs Labs
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Build 3D Animated Safety Induction - Tech EHS
Build 3D Animated Safety Induction - Tech EHSBuild 3D Animated Safety Induction - Tech EHS
Build 3D Animated Safety Induction - Tech EHS
TECH EHS Solution
 
Transcript: Canadian book publishing: Insights from the latest salary survey ...
Transcript: Canadian book publishing: Insights from the latest salary survey ...Transcript: Canadian book publishing: Insights from the latest salary survey ...
Transcript: Canadian book publishing: Insights from the latest salary survey ...
BookNet Canada
 
Web and Graphics Designing Training in Rajpura
Web and Graphics Designing Training in RajpuraWeb and Graphics Designing Training in Rajpura
Web and Graphics Designing Training in Rajpura
Erginous Technology
 
Vibe Coding_ Develop a web application using AI (1).pdf
Vibe Coding_ Develop a web application using AI (1).pdfVibe Coding_ Develop a web application using AI (1).pdf
Vibe Coding_ Develop a web application using AI (1).pdf
Baiju Muthukadan
 
AsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API DesignAsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API Design
leonid54
 
TrsLabs Consultants - DeFi, WEb3, Token Listing
TrsLabs Consultants - DeFi, WEb3, Token ListingTrsLabs Consultants - DeFi, WEb3, Token Listing
TrsLabs Consultants - DeFi, WEb3, Token Listing
Trs Labs
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptxReimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
John Moore
 
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent LasterAI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
All Things Open
 
Unlocking Generative AI in your Web Apps
Unlocking Generative AI in your Web AppsUnlocking Generative AI in your Web Apps
Unlocking Generative AI in your Web Apps
Maximiliano Firtman
 
TrsLabs - Leverage the Power of UPI Payments
TrsLabs - Leverage the Power of UPI PaymentsTrsLabs - Leverage the Power of UPI Payments
TrsLabs - Leverage the Power of UPI Payments
Trs Labs
 
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Markus Eisele
 

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.
  • 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
  • 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

Editor's Notes

  • #2: <number>
  • #7: <number>