SlideShare a Scribd company logo
BIG oIN
JAVASCRIPT
PART ONE
What is Big O?
Big O Notation is used to show how efficient an algorithm
or function is, in relative to its input size.
To measure the efficiency of an algorithm, we need to
consider two things:
Big-O captures the upper bound to show how much time or
memory an algorithm would require in the worst case
scenario as the input size grows.
● Time Complexity: How much time does it take to run
completely?
● Space Complexity: How much extra space does it require
in the process?
Each and every function or logic or methods or class
that we write falls under one of the Big O
expressions listed below,
O(1) 🤩 Best
O(Log n) 😃 Better
O(n)
O(n log n)
🙂 Normal
O(n^2)
🙃 Not Bad
☹ Bad
O(n^3) 😖 Worst
How Big O is expressed?
We programmers always come up with multiple solutions.
But how do we make sure that approach we took is the best?
This is where Big O comes into picture.
Let us consider an example to sum up the numbers from 1 to n.
// A function with O(n)
function addUpto(n) {
let total = 0;
for(let i=1; i<=n; i++){
total += i;
}
return total;
}
addUpto(10);
//55
// A function with O(1)
function addUpto(n) {
return n * ( n + 1 ) / 2;
}
addUpto(10);
//55
Why we need a Big O?
STAY AROUND
FOR THE
NEXT PART!
We will cover a bit more on the Big O.

More Related Content

Similar to What is Big O in JavaScript - Part-1 (20)

PPTX
Analysis of algorithms
S.Shayan Daneshvar
 
PPT
Complexity analysis
KaranAgarwal71
 
PPTX
Analysis of algorithms
Asen Bozhilov
 
PPTX
Daa unit 6_efficiency of algorithms
snehajiyani
 
PDF
Big omega
Rajesh K Shukla
 
PPT
Slides_Unit04_ComplexityAnalysis- Big-O notation
drsomya2019
 
PPTX
Asymptotic_Notations_v2_1709293258280.pptx
prasanna220904
 
PPTX
Algorithm Complexity & Big-O Analysis
Ömer Faruk Öztürk
 
PPTX
CMSC 56 | Lecture 8: Growth of Functions
allyn joy calcaben
 
PPTX
Algorithm Analysis
Megha V
 
PPTX
Dr hasany 2467_16649_1_lec-2-zabist
Gatewayggg Testeru
 
PPTX
Computational Complexity.pptx
EnosSalar
 
PPT
Analysis of algo
Maneesha Srivastav
 
PPTX
DAA Week 2 slide for design algorithm and analysis.pptx
Abdulahad481035
 
PDF
Computer Science Engineering : Data structure & algorithm, THE GATE ACADEMY
klirantga
 
PPTX
Unit ii algorithm
Tribhuvan University
 
PPT
Algorithum Analysis
Ain-ul-Moiz Khawaja
 
PDF
ESINF03-AlgAnalis.pdfESINF03-AlgAnalis.pdf
LusArajo20
 
PPTX
CS 161 Section 1 Slides - Stanford University
kneeslappercr
 
PPTX
Asymptotic Notations
NagendraK18
 
Analysis of algorithms
S.Shayan Daneshvar
 
Complexity analysis
KaranAgarwal71
 
Analysis of algorithms
Asen Bozhilov
 
Daa unit 6_efficiency of algorithms
snehajiyani
 
Big omega
Rajesh K Shukla
 
Slides_Unit04_ComplexityAnalysis- Big-O notation
drsomya2019
 
Asymptotic_Notations_v2_1709293258280.pptx
prasanna220904
 
Algorithm Complexity & Big-O Analysis
Ömer Faruk Öztürk
 
CMSC 56 | Lecture 8: Growth of Functions
allyn joy calcaben
 
Algorithm Analysis
Megha V
 
Dr hasany 2467_16649_1_lec-2-zabist
Gatewayggg Testeru
 
Computational Complexity.pptx
EnosSalar
 
Analysis of algo
Maneesha Srivastav
 
DAA Week 2 slide for design algorithm and analysis.pptx
Abdulahad481035
 
Computer Science Engineering : Data structure & algorithm, THE GATE ACADEMY
klirantga
 
Unit ii algorithm
Tribhuvan University
 
Algorithum Analysis
Ain-ul-Moiz Khawaja
 
ESINF03-AlgAnalis.pdfESINF03-AlgAnalis.pdf
LusArajo20
 
CS 161 Section 1 Slides - Stanford University
kneeslappercr
 
Asymptotic Notations
NagendraK18
 

More from Ideas2IT Technologies (20)

PDF
Version comaparison in JavaScript
Ideas2IT Technologies
 
PDF
Currying in JavaScript
Ideas2IT Technologies
 
PDF
JS Testing Frameworks
Ideas2IT Technologies
 
PDF
Cool usage of Encoding and Decoding a URI in Javascript
Ideas2IT Technologies
 
PDF
Iterables and Iterators in JavaScript
Ideas2IT Technologies
 
PDF
String comparison in javascript
Ideas2IT Technologies
 
PDF
JavaScript symbols
Ideas2IT Technologies
 
PDF
Json.parse() in JavaScript
Ideas2IT Technologies
 
PDF
Bubble sort in Java Script
Ideas2IT Technologies
 
PDF
Performance analysis in merging arrays - JavaScript
Ideas2IT Technologies
 
PDF
Nullish coalescing in JavaScript
Ideas2IT Technologies
 
PDF
Conditionally add keys in JavaScript
Ideas2IT Technologies
 
PDF
Variable hoisting in JavaScript
Ideas2IT Technologies
 
PDF
Formidable ES6 spread operator in JavaScript
Ideas2IT Technologies
 
PDF
Logging in JavaScript - Part-5
Ideas2IT Technologies
 
PDF
Logging in JavaScript - Part-4
Ideas2IT Technologies
 
PDF
Logging in JavaScript - Part-3
Ideas2IT Technologies
 
PDF
Logging in JavaScript - part-2
Ideas2IT Technologies
 
PDF
Logging in JavaScript - part-1
Ideas2IT Technologies
 
PDF
Array vs set in JavaScript
Ideas2IT Technologies
 
Version comaparison in JavaScript
Ideas2IT Technologies
 
Currying in JavaScript
Ideas2IT Technologies
 
JS Testing Frameworks
Ideas2IT Technologies
 
Cool usage of Encoding and Decoding a URI in Javascript
Ideas2IT Technologies
 
Iterables and Iterators in JavaScript
Ideas2IT Technologies
 
String comparison in javascript
Ideas2IT Technologies
 
JavaScript symbols
Ideas2IT Technologies
 
Json.parse() in JavaScript
Ideas2IT Technologies
 
Bubble sort in Java Script
Ideas2IT Technologies
 
Performance analysis in merging arrays - JavaScript
Ideas2IT Technologies
 
Nullish coalescing in JavaScript
Ideas2IT Technologies
 
Conditionally add keys in JavaScript
Ideas2IT Technologies
 
Variable hoisting in JavaScript
Ideas2IT Technologies
 
Formidable ES6 spread operator in JavaScript
Ideas2IT Technologies
 
Logging in JavaScript - Part-5
Ideas2IT Technologies
 
Logging in JavaScript - Part-4
Ideas2IT Technologies
 
Logging in JavaScript - Part-3
Ideas2IT Technologies
 
Logging in JavaScript - part-2
Ideas2IT Technologies
 
Logging in JavaScript - part-1
Ideas2IT Technologies
 
Array vs set in JavaScript
Ideas2IT Technologies
 
Ad

Recently uploaded (20)

PDF
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
PDF
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
PPTX
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PDF
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
PPTX
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
PDF
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
PPTX
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
PDF
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
PDF
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
PDF
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
PDF
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
PDF
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
PPTX
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
PDF
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
PPTX
Transforming Mining & Engineering Operations with Odoo ERP | Streamline Proje...
SatishKumar2651
 
PDF
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
PDF
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
PPTX
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
PDF
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
Transforming Mining & Engineering Operations with Odoo ERP | Streamline Proje...
SatishKumar2651
 
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
Ad

What is Big O in JavaScript - Part-1

  • 2. What is Big O? Big O Notation is used to show how efficient an algorithm or function is, in relative to its input size. To measure the efficiency of an algorithm, we need to consider two things: Big-O captures the upper bound to show how much time or memory an algorithm would require in the worst case scenario as the input size grows. ● Time Complexity: How much time does it take to run completely? ● Space Complexity: How much extra space does it require in the process?
  • 3. Each and every function or logic or methods or class that we write falls under one of the Big O expressions listed below, O(1) 🤩 Best O(Log n) 😃 Better O(n) O(n log n) 🙂 Normal O(n^2) 🙃 Not Bad ☹ Bad O(n^3) 😖 Worst How Big O is expressed?
  • 4. We programmers always come up with multiple solutions. But how do we make sure that approach we took is the best? This is where Big O comes into picture. Let us consider an example to sum up the numbers from 1 to n. // A function with O(n) function addUpto(n) { let total = 0; for(let i=1; i<=n; i++){ total += i; } return total; } addUpto(10); //55 // A function with O(1) function addUpto(n) { return n * ( n + 1 ) / 2; } addUpto(10); //55 Why we need a Big O?
  • 5. STAY AROUND FOR THE NEXT PART! We will cover a bit more on the Big O.