SlideShare une entreprise Scribd logo
1  sur  16
Big O Notation
Hamza Mushtaq
DCS&IT
Session 2016-2020
Islamia University Bahwalpur
A Brief Overview
Time Complexity
In the time complexity analysis we define the time as
a function of the problem size and try to estimate the
growth of the execution time with the growth in
problem size.
Memory Space
• The space require by the program to save input data and results in memory
(RAM).
History of Big-O-Notation
• Big O notation (with a capital letter O, not a zero), also called Landau's
symbol, is a symbolism used in complexity theory, computer science,
and mathematics to describe the basic behavior of functions. Basically, it
tells you how fast a function grows or declines.
• Landau's symbol comes from the name of the German mathematician
Edmund Landau who invented the notation.
• The letter O is used because the rate of growth of a function is also
called its order.
What is
Big O notation???
It describes
• Efficiency of an Algorithm
• Time Factor of an Algorithm
• Space Complexity of an Algorithm
It is represented by O(n) where n is the number of operations.
O(1)
void print(int index,int values[]){
cout<<“the value at index”<<index<< “ is ”<<value[index];
}
You can directly access the index element of the
array, so no matter how big the array gets, the
time it takes to access the element won’t change.
O(n)
void print(int index, int values[]){
for(int x=0;x<index;x++)cout<<index<<“ .”<<value[index]<<endl;
}
As you increase the size of the array, the time for this
algorithm will increase proportionally. An array of 50 will
take twice the time as an array of 25 and half the time of
an array of 100.
O(n2)
• int CompareToAllNumbers (int array1[ ] ,int index1,int array2[ ],int index2){
• for (int x = 0; x < index1; x++)
• {bool isMin;
• for (int y = 0; y < index2; y++)
• { if( array[x] > array[y])
• isMin = false;
• }if(isMin)
• break; }
• return array[x];}
If you add one element to array, you need to go through the entire
rest of the array one additional time. As the input grows, the
time required to run the algorithm will grow quite quickly.
O(n!)
• Travelling salesman problem
in this problem as the number of cities increases
the runtime also increases accordingly by a factor
of cities factorial.
int CompareSmallestNumber (int array[ ])
{ int x, curMin;
curMin = array[0];
for (x = 1; x < 10; x++)
{ if( array[x] < curMin)
curMin = array[x];}
return curMin;}
int CompareToAllNumbers (int array[ ])
{bool is Min;
int x, y;
for (int x = 0; x < 10; x++)
{ isMin = true;
for (int y = 0; y < 10; y++)
{ if( array[x] > array[y])
isMin = false;
}if(isMin)
break; }
return array[x];}
We are having two different algorithms
to find the smallest element in the array
• Uses array to store elements
• Compares a temporary variable in the array
• The Big O notation for it is O(n)
This algorithm is efficient and effective as its
O is small as compare to the 2nd algorithm
And hence it gives the best result in less time.
• Uses array to store elements
• Compares the array with array itself
• The big O notation for it is O(n2)
This algorithm is less effective than the other
Beacause this algo has a high Big O and hence
It is more time taking and less effective.
Worst Best 
SCENARIOS
BEST
AVERAGE
WORST
Best case:
When the algorithm takes less
run time w.r.t the given inputs/data.
Best case also defines as Big Ω.
Average case:
When the algorithm takes
average run time w.r.t to the input /data.
This is also known as BigΘ.
Worst case:
When the algorithm takes higher runtime
as compared to the given inputs/data.
Worst case is also called as Big O.
The End
of presentation

Contenu connexe

Tendances

Algorithms Lecture 2: Analysis of Algorithms I
Algorithms Lecture 2: Analysis of Algorithms IAlgorithms Lecture 2: Analysis of Algorithms I
Algorithms Lecture 2: Analysis of Algorithms IMohamed Loey
 
Hashing Technique In Data Structures
Hashing Technique In Data StructuresHashing Technique In Data Structures
Hashing Technique In Data StructuresSHAKOOR AB
 
Algorithm Complexity & Big-O Analysis
Algorithm Complexity & Big-O AnalysisAlgorithm Complexity & Big-O Analysis
Algorithm Complexity & Big-O AnalysisÖmer Faruk Öztürk
 
9 big o-notation
9 big o-notation9 big o-notation
9 big o-notationirdginfo
 
Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)swapnac12
 
Design and analysis of algorithms
Design and analysis of algorithmsDesign and analysis of algorithms
Design and analysis of algorithmsDr Geetha Mohan
 
Big o notation
Big o notationBig o notation
Big o notationkeb97
 
Our presentation on algorithm design
Our presentation on algorithm designOur presentation on algorithm design
Our presentation on algorithm designNahid Hasan
 
Algorithm analysis in fundamentals of data structure
Algorithm analysis in fundamentals of data structureAlgorithm analysis in fundamentals of data structure
Algorithm analysis in fundamentals of data structureVrushali Dhanokar
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithmsJulie Iskander
 
Theory of Computation
Theory of ComputationTheory of Computation
Theory of ComputationShiraz316
 
Design & Analysis of Algorithms Lecture Notes
Design & Analysis of Algorithms Lecture NotesDesign & Analysis of Algorithms Lecture Notes
Design & Analysis of Algorithms Lecture NotesFellowBuddy.com
 

Tendances (20)

Algorithms Lecture 2: Analysis of Algorithms I
Algorithms Lecture 2: Analysis of Algorithms IAlgorithms Lecture 2: Analysis of Algorithms I
Algorithms Lecture 2: Analysis of Algorithms I
 
Hashing Technique In Data Structures
Hashing Technique In Data StructuresHashing Technique In Data Structures
Hashing Technique In Data Structures
 
Complexity analysis in Algorithms
Complexity analysis in AlgorithmsComplexity analysis in Algorithms
Complexity analysis in Algorithms
 
Algorithm Complexity & Big-O Analysis
Algorithm Complexity & Big-O AnalysisAlgorithm Complexity & Big-O Analysis
Algorithm Complexity & Big-O Analysis
 
Time andspacecomplexity
Time andspacecomplexityTime andspacecomplexity
Time andspacecomplexity
 
9 big o-notation
9 big o-notation9 big o-notation
9 big o-notation
 
Greedy Algorihm
Greedy AlgorihmGreedy Algorihm
Greedy Algorihm
 
Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)
 
Complexity of Algorithm
Complexity of AlgorithmComplexity of Algorithm
Complexity of Algorithm
 
Greedy Algorithms
Greedy AlgorithmsGreedy Algorithms
Greedy Algorithms
 
Daa notes 1
Daa notes 1Daa notes 1
Daa notes 1
 
Design and analysis of algorithms
Design and analysis of algorithmsDesign and analysis of algorithms
Design and analysis of algorithms
 
Big o notation
Big o notationBig o notation
Big o notation
 
Our presentation on algorithm design
Our presentation on algorithm designOur presentation on algorithm design
Our presentation on algorithm design
 
Algorithm analysis in fundamentals of data structure
Algorithm analysis in fundamentals of data structureAlgorithm analysis in fundamentals of data structure
Algorithm analysis in fundamentals of data structure
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithms
 
Theory of Computation
Theory of ComputationTheory of Computation
Theory of Computation
 
Design & Analysis of Algorithms Lecture Notes
Design & Analysis of Algorithms Lecture NotesDesign & Analysis of Algorithms Lecture Notes
Design & Analysis of Algorithms Lecture Notes
 
Np complete
Np completeNp complete
Np complete
 
Knapsack Problem
Knapsack ProblemKnapsack Problem
Knapsack Problem
 

En vedette

Asymptotic Notations
Asymptotic NotationsAsymptotic Notations
Asymptotic NotationsRishabh Soni
 
Divide and Conquer - Part 1
Divide and Conquer - Part 1Divide and Conquer - Part 1
Divide and Conquer - Part 1Amrinder Arora
 
Data structures and Big O notation
Data structures and Big O notationData structures and Big O notation
Data structures and Big O notationMuthiah Abbhirami
 
Divide and Conquer - Part II - Quickselect and Closest Pair of Points
Divide and Conquer - Part II - Quickselect and Closest Pair of PointsDivide and Conquer - Part II - Quickselect and Closest Pair of Points
Divide and Conquer - Part II - Quickselect and Closest Pair of PointsAmrinder Arora
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notationsNikhil Sharma
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notationsEhtisham Ali
 
Recurrence relationclass 5
Recurrence relationclass 5Recurrence relationclass 5
Recurrence relationclass 5Kumar
 
01. design & analysis of agorithm intro & complexity analysis
01. design & analysis of agorithm intro & complexity analysis01. design & analysis of agorithm intro & complexity analysis
01. design & analysis of agorithm intro & complexity analysisOnkar Nath Sharma
 
Sets and disjoint sets union123
Sets and disjoint sets union123Sets and disjoint sets union123
Sets and disjoint sets union123Ankita Goyal
 
02 asymptotic-notation-and-recurrences
02 asymptotic-notation-and-recurrences02 asymptotic-notation-and-recurrences
02 asymptotic-notation-and-recurrencesNoushadur Shoukhin
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexityparamita30
 
Algorithm Design and Complexity - Course 1&2
Algorithm Design and Complexity - Course 1&2Algorithm Design and Complexity - Course 1&2
Algorithm Design and Complexity - Course 1&2Traian Rebedea
 
03 Analysis of Algorithms: Probabilistic Analysis
03 Analysis of Algorithms: Probabilistic Analysis03 Analysis of Algorithms: Probabilistic Analysis
03 Analysis of Algorithms: Probabilistic AnalysisAndres Mendez-Vazquez
 
Radix 4 FFT algorithm and it time complexity computation
Radix 4 FFT algorithm and it time complexity computationRadix 4 FFT algorithm and it time complexity computation
Radix 4 FFT algorithm and it time complexity computationRaj Jaiswal
 

En vedette (20)

Algorithm big o
Algorithm big oAlgorithm big o
Algorithm big o
 
Asymptotic Notations
Asymptotic NotationsAsymptotic Notations
Asymptotic Notations
 
Divide and Conquer - Part 1
Divide and Conquer - Part 1Divide and Conquer - Part 1
Divide and Conquer - Part 1
 
Big o
Big oBig o
Big o
 
Data structures and Big O notation
Data structures and Big O notationData structures and Big O notation
Data structures and Big O notation
 
Divide and Conquer - Part II - Quickselect and Closest Pair of Points
Divide and Conquer - Part II - Quickselect and Closest Pair of PointsDivide and Conquer - Part II - Quickselect and Closest Pair of Points
Divide and Conquer - Part II - Quickselect and Closest Pair of Points
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
 
Complexity
ComplexityComplexity
Complexity
 
Recurrence relationclass 5
Recurrence relationclass 5Recurrence relationclass 5
Recurrence relationclass 5
 
01. design & analysis of agorithm intro & complexity analysis
01. design & analysis of agorithm intro & complexity analysis01. design & analysis of agorithm intro & complexity analysis
01. design & analysis of agorithm intro & complexity analysis
 
Sets and disjoint sets union123
Sets and disjoint sets union123Sets and disjoint sets union123
Sets and disjoint sets union123
 
02 Notes Divide and Conquer
02 Notes Divide and Conquer02 Notes Divide and Conquer
02 Notes Divide and Conquer
 
02 asymptotic-notation-and-recurrences
02 asymptotic-notation-and-recurrences02 asymptotic-notation-and-recurrences
02 asymptotic-notation-and-recurrences
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexity
 
Algorithm Introduction
Algorithm IntroductionAlgorithm Introduction
Algorithm Introduction
 
Algorithm Design and Complexity - Course 1&2
Algorithm Design and Complexity - Course 1&2Algorithm Design and Complexity - Course 1&2
Algorithm Design and Complexity - Course 1&2
 
03 Analysis of Algorithms: Probabilistic Analysis
03 Analysis of Algorithms: Probabilistic Analysis03 Analysis of Algorithms: Probabilistic Analysis
03 Analysis of Algorithms: Probabilistic Analysis
 
13 Amortized Analysis
13 Amortized Analysis13 Amortized Analysis
13 Amortized Analysis
 
Radix 4 FFT algorithm and it time complexity computation
Radix 4 FFT algorithm and it time complexity computationRadix 4 FFT algorithm and it time complexity computation
Radix 4 FFT algorithm and it time complexity computation
 

Similaire à Big o notation

Computational Complexity.pptx
Computational Complexity.pptxComputational Complexity.pptx
Computational Complexity.pptxEnosSalar
 
Introduction to Algorithms
Introduction to AlgorithmsIntroduction to Algorithms
Introduction to AlgorithmsVenkatesh Iyer
 
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
 
Algorithm Complexity and Main Concepts
Algorithm Complexity and Main ConceptsAlgorithm Complexity and Main Concepts
Algorithm Complexity and Main ConceptsAdelina Ahadova
 
VCE Unit 01 (2).pptx
VCE Unit 01 (2).pptxVCE Unit 01 (2).pptx
VCE Unit 01 (2).pptxskilljiolms
 
19. algorithms and-complexity
19. algorithms and-complexity19. algorithms and-complexity
19. algorithms and-complexityshowkat27
 
Advance data structure & algorithm
Advance data structure & algorithmAdvance data structure & algorithm
Advance data structure & algorithmK Hari Shankar
 
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
 
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
 
data structures using C 2 sem BCA univeristy of mysore
data structures using C 2 sem BCA univeristy of mysoredata structures using C 2 sem BCA univeristy of mysore
data structures using C 2 sem BCA univeristy of mysoreambikavenkatesh2
 
Data Structure & Algorithms - Mathematical
Data Structure & Algorithms - MathematicalData Structure & Algorithms - Mathematical
Data Structure & Algorithms - Mathematicalbabuk110
 
Data Structure & Algorithms - Introduction
Data Structure & Algorithms - IntroductionData Structure & Algorithms - Introduction
Data Structure & Algorithms - Introductionbabuk110
 
TIME EXECUTION OF DIFFERENT SORTED ALGORITHMS
TIME EXECUTION   OF  DIFFERENT SORTED ALGORITHMSTIME EXECUTION   OF  DIFFERENT SORTED ALGORITHMS
TIME EXECUTION OF DIFFERENT SORTED ALGORITHMSTanya Makkar
 
Algorithm analysis (All in one)
Algorithm analysis (All in one)Algorithm analysis (All in one)
Algorithm analysis (All in one)jehan1987
 
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
 

Similaire à Big o notation (20)

Computational Complexity.pptx
Computational Complexity.pptxComputational Complexity.pptx
Computational Complexity.pptx
 
Introduction to Algorithms
Introduction to AlgorithmsIntroduction to Algorithms
Introduction to Algorithms
 
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 ...
 
Algorithm Complexity and Main Concepts
Algorithm Complexity and Main ConceptsAlgorithm Complexity and Main Concepts
Algorithm Complexity and Main Concepts
 
VCE Unit 01 (2).pptx
VCE Unit 01 (2).pptxVCE Unit 01 (2).pptx
VCE Unit 01 (2).pptx
 
19. algorithms and-complexity
19. algorithms and-complexity19. algorithms and-complexity
19. algorithms and-complexity
 
Advance data structure & algorithm
Advance data structure & algorithmAdvance data structure & algorithm
Advance data structure & algorithm
 
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
 
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..
 
Searching Algorithms
Searching AlgorithmsSearching Algorithms
Searching Algorithms
 
3 analysis.gtm
3 analysis.gtm3 analysis.gtm
3 analysis.gtm
 
Unit ii algorithm
Unit   ii algorithmUnit   ii algorithm
Unit ii algorithm
 
data structures using C 2 sem BCA univeristy of mysore
data structures using C 2 sem BCA univeristy of mysoredata structures using C 2 sem BCA univeristy of mysore
data structures using C 2 sem BCA univeristy of mysore
 
Data Structure & Algorithms - Mathematical
Data Structure & Algorithms - MathematicalData Structure & Algorithms - Mathematical
Data Structure & Algorithms - Mathematical
 
Data Structure & Algorithms - Introduction
Data Structure & Algorithms - IntroductionData Structure & Algorithms - Introduction
Data Structure & Algorithms - Introduction
 
TIME EXECUTION OF DIFFERENT SORTED ALGORITHMS
TIME EXECUTION   OF  DIFFERENT SORTED ALGORITHMSTIME EXECUTION   OF  DIFFERENT SORTED ALGORITHMS
TIME EXECUTION OF DIFFERENT SORTED ALGORITHMS
 
Algorithm analysis (All in one)
Algorithm analysis (All in one)Algorithm analysis (All in one)
Algorithm analysis (All in one)
 
Analysis of Algorithum
Analysis of AlgorithumAnalysis of Algorithum
Analysis of Algorithum
 
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
 
Lec7
Lec7Lec7
Lec7
 

Dernier

Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...anjaliyadav012327
 
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
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
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
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...Pooja Nehwal
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
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
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxShobhayan Kirtania
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 

Dernier (20)

Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
 
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
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
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
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
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
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 

Big o notation

  • 1. Big O Notation Hamza Mushtaq DCS&IT Session 2016-2020 Islamia University Bahwalpur A Brief Overview
  • 2. Time Complexity In the time complexity analysis we define the time as a function of the problem size and try to estimate the growth of the execution time with the growth in problem size.
  • 3. Memory Space • The space require by the program to save input data and results in memory (RAM).
  • 4. History of Big-O-Notation • Big O notation (with a capital letter O, not a zero), also called Landau's symbol, is a symbolism used in complexity theory, computer science, and mathematics to describe the basic behavior of functions. Basically, it tells you how fast a function grows or declines. • Landau's symbol comes from the name of the German mathematician Edmund Landau who invented the notation. • The letter O is used because the rate of growth of a function is also called its order.
  • 5. What is Big O notation???
  • 6. It describes • Efficiency of an Algorithm • Time Factor of an Algorithm • Space Complexity of an Algorithm It is represented by O(n) where n is the number of operations.
  • 7. O(1) void print(int index,int values[]){ cout<<“the value at index”<<index<< “ is ”<<value[index]; } You can directly access the index element of the array, so no matter how big the array gets, the time it takes to access the element won’t change.
  • 8. O(n) void print(int index, int values[]){ for(int x=0;x<index;x++)cout<<index<<“ .”<<value[index]<<endl; } As you increase the size of the array, the time for this algorithm will increase proportionally. An array of 50 will take twice the time as an array of 25 and half the time of an array of 100.
  • 9. O(n2) • int CompareToAllNumbers (int array1[ ] ,int index1,int array2[ ],int index2){ • for (int x = 0; x < index1; x++) • {bool isMin; • for (int y = 0; y < index2; y++) • { if( array[x] > array[y]) • isMin = false; • }if(isMin) • break; } • return array[x];} If you add one element to array, you need to go through the entire rest of the array one additional time. As the input grows, the time required to run the algorithm will grow quite quickly.
  • 10. O(n!) • Travelling salesman problem in this problem as the number of cities increases the runtime also increases accordingly by a factor of cities factorial.
  • 11.
  • 12. int CompareSmallestNumber (int array[ ]) { int x, curMin; curMin = array[0]; for (x = 1; x < 10; x++) { if( array[x] < curMin) curMin = array[x];} return curMin;} int CompareToAllNumbers (int array[ ]) {bool is Min; int x, y; for (int x = 0; x < 10; x++) { isMin = true; for (int y = 0; y < 10; y++) { if( array[x] > array[y]) isMin = false; }if(isMin) break; } return array[x];} We are having two different algorithms to find the smallest element in the array
  • 13. • Uses array to store elements • Compares a temporary variable in the array • The Big O notation for it is O(n) This algorithm is efficient and effective as its O is small as compare to the 2nd algorithm And hence it gives the best result in less time. • Uses array to store elements • Compares the array with array itself • The big O notation for it is O(n2) This algorithm is less effective than the other Beacause this algo has a high Big O and hence It is more time taking and less effective. Worst Best 
  • 15. Best case: When the algorithm takes less run time w.r.t the given inputs/data. Best case also defines as Big Ω. Average case: When the algorithm takes average run time w.r.t to the input /data. This is also known as BigΘ. Worst case: When the algorithm takes higher runtime as compared to the given inputs/data. Worst case is also called as Big O.