SlideShare ist ein Scribd-Unternehmen logo
Time Complexity
Srivaths P
Goal:
• Understand time complexity
• Understand Big-O notation for time complexity.
• Evaluate time complexity of an algorithm.
• Evaluate expected time complexity based on the given
constraints of a problem.
• Evaluating space complexity of a program.
• Common verdicts of submissions.
What is an Elementary Operation?
An operation that takes constant time is called
elementary operation.
Example:
• Arithmetic operations
• Comparison of primitive types
• Input and output of primitive types
108 operations ≈ 1 second
Quiz 1
1. Is the following an elementary operation?
2. Is the following an elementary operation?
What is Time Complexity?
Time complexity is a function to describe the
approximate amount of operations an algorithm
requires for the given input.
We can calculate approximate execution time of
code using time complexity and constraints.
Big-O notation
Big-O of an algorithm is a function to calculate the
worst case time complexity of the algorithm.
It is written as O(worst case time complexity)
Big-O is used to calculate the approximate upper
bound of the algorithm. It expresses how the run
time of the algorithm grows relative to the input.
More convenient and useful than other notations.
Rules for Big-O notation
• Should not have constants.
• Should not have constant factors.
• Only include the fastest growing function
for each variable.
• Can never be 0. Has to be atleast O(1)
Example function: 2(N2) + 4N + 4(M3 + 5) + 10
Quiz 2
1. (N+M) / K
2. N(N+1)/2
3. N2 + M(N2) + M2(N) + NM
4. N3/64 + 20N + (32NM)2
Calculate Time Complexity of
an Algorithm
Time complexity usually depends on:
• Loops
• Recursion
Time complexity of recursive algorithms will not
be covered.
Note: Usage of STL counts for time complexity
Calculate Time Complexity of
an Algorithm
If there are nested loops, multiply the expected
number of iterations of the loops
Example:
Quiz 3
Find the time complexity of the following code
snippets in Big-O notation:
1.
2.
Quiz 3
3.
4.
Time Complexity based on Constraints
Feasible Big-O
Function
Maximum N Example Algorithms
O(𝑁!) 10 All permutations of a list
O(𝑁3
) 400 Multiplication of two matrices
O(𝑁2) 5000
Square grid, bubble sort,
insertion sort
O(𝑁 𝑁) 105 Usually related to factoring
O(𝑁𝑙𝑜𝑔𝑁) 106 Merge sort, binary search for N times
O(𝑁) 107 Linear search, reversing an array,
string comparison
O( 𝑁) 1012 Factors of a number
O(𝑙𝑜𝑔𝑁), O(1) 1018 Binary search,
Constant time formulas
Space Complexity
Space complexity is similar to time complexity,
except it measures the amount of memory.
Any datatype that has constant memory takes
O(1) space.
Example: int, char, long long int, double, etc.
Space Complexity
Most problems have a memory limit of
256MB or ~2e8 bytes.
Datatype No. of bytes
char 1
int 4
float 4
long long int 8
double 8
long double 16
Verdict of a solution
• AC: Accepted
• WA: Wrong Answer
• TLE: Time Limit Exceeded
• MLE: Memory Limit Exceeded
• RE: Runtime Error
– NZEC: Non Zero Exit Code
– SIGSEGV: Usually due to out of bounds
– SIGFPE: Usually division or modulo by 0
– SIGABRT: Due to assert statements
Points to note:
• Identify the variables that contribute to time
complexity.
• Just because constraints allow slower solutions,
doesn’t mean there’s not a fast solution.
For example, if N <= 1000, then both O(N2) and O(N)
can pass.
• Testcases matter, unless there’s a limit explicitly
imposed in the constraints.
• The constants and constant factors removed when
calculating Big-O still matter.
Problems to test understanding
• https://codeforces.com/contest/1647/problem/A
• https://codeforces.com/problemset/problem/1538/C
• https://www.codechef.com/MARCH221D/problems/DISCUS
• https://www.codechef.com/MARCH221D/problems/WORDLE
• https://www.codechef.com/MARCH221D/problems/CHFDBT
• https://codeforces.com/contest/1651/problem/B
• https://codeforces.com/contest/1651/problem/A
• https://codeforces.com/problemset/problem/919/B
For more practice, try to figure out the time
complexity for any random problem.
Further Reading:
• https://towardsdatascience.com/essential-programming-
time-complexity-a95bb2608cac
• https://www.youtube.com/watch?v=9TlHvipP5yA
https://www.youtube.com/watch?v=9SgLBjXqwd4
https://www.youtube.com/watch?v=I0DTkS1LJ2k
• https://adrianmejia.com/most-popular-algorithms-time-
complexity-every-programmer-should-know-free-online-
tutorial-course/ (advanced)

Weitere ähnliche Inhalte

Ähnlich wie Time_Complexity.pptx

Ch1. Analysis of Algorithms.pdf
Ch1. Analysis of Algorithms.pdfCh1. Analysis of Algorithms.pdf
Ch1. Analysis of Algorithms.pdf
zoric99
 
Cs 331 Data Structures
Cs 331 Data StructuresCs 331 Data Structures
Unit 1, ADA.pptx
Unit 1, ADA.pptxUnit 1, ADA.pptx
Unit 1, ADA.pptx
jinkhatima
 
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...
AntareepMajumder
 
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
Mohamed Loey
 
Analysis of algorithms
Analysis of algorithmsAnalysis of algorithms
Analysis of algorithms
iqbalphy1
 
Unit 1.pptx
Unit 1.pptxUnit 1.pptx
Unit 1.pptx
DeepakYadav656387
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
subhashchandra197
 
Analysis of algorithn class 2
Analysis of algorithn class 2Analysis of algorithn class 2
Analysis of algorithn class 2
Kumar
 
Algorithm
AlgorithmAlgorithm
Algorithm
Anirban Sarkar
 
Algorithm
AlgorithmAlgorithm
Algorithm
Syam Kumar
 
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
vijipersonal2012
 
Analysis and Algorithms: basic Introduction
Analysis and Algorithms: basic IntroductionAnalysis and Algorithms: basic Introduction
Analysis and Algorithms: basic Introduction
ssuseraf8b2f
 
DAA-Unit1.pptx
DAA-Unit1.pptxDAA-Unit1.pptx
DAA-Unit1.pptx
NishaS88
 
Analysis of algorithms
Analysis of algorithmsAnalysis of algorithms
Analysis of algorithms
Asen Bozhilov
 
Unit ii algorithm
Unit   ii algorithmUnit   ii algorithm
Unit ii algorithm
Tribhuvan University
 
Complexity of Algorithm
Complexity of AlgorithmComplexity of Algorithm
Complexity of Algorithm
Muhammad Muzammal
 
Algorithms & Complexity Calculation
Algorithms & Complexity CalculationAlgorithms & Complexity Calculation
Algorithms & Complexity Calculation
Akhil Kaushik
 
2. Asymptotic Notations and Complexity Analysis.pptx
2. Asymptotic Notations and Complexity Analysis.pptx2. Asymptotic Notations and Complexity Analysis.pptx
2. Asymptotic Notations and Complexity Analysis.pptx
Rams715121
 
Design Analysis of Alogorithm 1 ppt 2024.pptx
Design Analysis of Alogorithm 1 ppt 2024.pptxDesign Analysis of Alogorithm 1 ppt 2024.pptx
Design Analysis of Alogorithm 1 ppt 2024.pptx
rajesshs31r
 

Ähnlich wie Time_Complexity.pptx (20)

Ch1. Analysis of Algorithms.pdf
Ch1. Analysis of Algorithms.pdfCh1. Analysis of Algorithms.pdf
Ch1. Analysis of Algorithms.pdf
 
Cs 331 Data Structures
Cs 331 Data StructuresCs 331 Data Structures
Cs 331 Data Structures
 
Unit 1, ADA.pptx
Unit 1, ADA.pptxUnit 1, ADA.pptx
Unit 1, ADA.pptx
 
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...
 
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
 
Analysis of algorithms
Analysis of algorithmsAnalysis of algorithms
Analysis of algorithms
 
Unit 1.pptx
Unit 1.pptxUnit 1.pptx
Unit 1.pptx
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
 
Analysis of algorithn class 2
Analysis of algorithn class 2Analysis of algorithn class 2
Analysis of algorithn class 2
 
Algorithm
AlgorithmAlgorithm
Algorithm
 
Algorithm
AlgorithmAlgorithm
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
 
Analysis and Algorithms: basic Introduction
Analysis and Algorithms: basic IntroductionAnalysis and Algorithms: basic Introduction
Analysis and Algorithms: basic Introduction
 
DAA-Unit1.pptx
DAA-Unit1.pptxDAA-Unit1.pptx
DAA-Unit1.pptx
 
Analysis of algorithms
Analysis of algorithmsAnalysis of algorithms
Analysis of algorithms
 
Unit ii algorithm
Unit   ii algorithmUnit   ii algorithm
Unit ii algorithm
 
Complexity of Algorithm
Complexity of AlgorithmComplexity of Algorithm
Complexity of Algorithm
 
Algorithms & Complexity Calculation
Algorithms & Complexity CalculationAlgorithms & Complexity Calculation
Algorithms & Complexity Calculation
 
2. Asymptotic Notations and Complexity Analysis.pptx
2. Asymptotic Notations and Complexity Analysis.pptx2. Asymptotic Notations and Complexity Analysis.pptx
2. Asymptotic Notations and Complexity Analysis.pptx
 
Design Analysis of Alogorithm 1 ppt 2024.pptx
Design Analysis of Alogorithm 1 ppt 2024.pptxDesign Analysis of Alogorithm 1 ppt 2024.pptx
Design Analysis of Alogorithm 1 ppt 2024.pptx
 

Kürzlich hochgeladen

Mechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdfMechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdf
21UME003TUSHARDEB
 
cnn.pptx Convolutional neural network used for image classication
cnn.pptx Convolutional neural network used for image classicationcnn.pptx Convolutional neural network used for image classication
cnn.pptx Convolutional neural network used for image classication
SakkaravarthiShanmug
 
Curve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods RegressionCurve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods Regression
Nada Hikmah
 
Rainfall intensity duration frequency curve statistical analysis and modeling...
Rainfall intensity duration frequency curve statistical analysis and modeling...Rainfall intensity duration frequency curve statistical analysis and modeling...
Rainfall intensity duration frequency curve statistical analysis and modeling...
bijceesjournal
 
Engineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdfEngineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdf
abbyasa1014
 
Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
Madan Karki
 
ITSM Integration with MuleSoft.pptx
ITSM  Integration with MuleSoft.pptxITSM  Integration with MuleSoft.pptx
ITSM Integration with MuleSoft.pptx
VANDANAMOHANGOUDA
 
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
IJECEIAES
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
171ticu
 
An Introduction to the Compiler Designss
An Introduction to the Compiler DesignssAn Introduction to the Compiler Designss
An Introduction to the Compiler Designss
ElakkiaU
 
Material for memory and display system h
Material for memory and display system hMaterial for memory and display system h
Material for memory and display system h
gowrishankartb2005
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
VICTOR MAESTRE RAMIREZ
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
insn4465
 
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURSCompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
RamonNovais6
 
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
shadow0702a
 
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
171ticu
 
Computational Engineering IITH Presentation
Computational Engineering IITH PresentationComputational Engineering IITH Presentation
Computational Engineering IITH Presentation
co23btech11018
 
Null Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAMNull Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAM
Divyanshu
 
Software Quality Assurance-se412-v11.ppt
Software Quality Assurance-se412-v11.pptSoftware Quality Assurance-se412-v11.ppt
Software Quality Assurance-se412-v11.ppt
TaghreedAltamimi
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Sinan KOZAK
 

Kürzlich hochgeladen (20)

Mechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdfMechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdf
 
cnn.pptx Convolutional neural network used for image classication
cnn.pptx Convolutional neural network used for image classicationcnn.pptx Convolutional neural network used for image classication
cnn.pptx Convolutional neural network used for image classication
 
Curve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods RegressionCurve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods Regression
 
Rainfall intensity duration frequency curve statistical analysis and modeling...
Rainfall intensity duration frequency curve statistical analysis and modeling...Rainfall intensity duration frequency curve statistical analysis and modeling...
Rainfall intensity duration frequency curve statistical analysis and modeling...
 
Engineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdfEngineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdf
 
Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
 
ITSM Integration with MuleSoft.pptx
ITSM  Integration with MuleSoft.pptxITSM  Integration with MuleSoft.pptx
ITSM Integration with MuleSoft.pptx
 
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
 
An Introduction to the Compiler Designss
An Introduction to the Compiler DesignssAn Introduction to the Compiler Designss
An Introduction to the Compiler Designss
 
Material for memory and display system h
Material for memory and display system hMaterial for memory and display system h
Material for memory and display system h
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
 
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURSCompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
 
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
 
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
 
Computational Engineering IITH Presentation
Computational Engineering IITH PresentationComputational Engineering IITH Presentation
Computational Engineering IITH Presentation
 
Null Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAMNull Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAM
 
Software Quality Assurance-se412-v11.ppt
Software Quality Assurance-se412-v11.pptSoftware Quality Assurance-se412-v11.ppt
Software Quality Assurance-se412-v11.ppt
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
 

Time_Complexity.pptx

  • 2. Goal: • Understand time complexity • Understand Big-O notation for time complexity. • Evaluate time complexity of an algorithm. • Evaluate expected time complexity based on the given constraints of a problem. • Evaluating space complexity of a program. • Common verdicts of submissions.
  • 3. What is an Elementary Operation? An operation that takes constant time is called elementary operation. Example: • Arithmetic operations • Comparison of primitive types • Input and output of primitive types 108 operations ≈ 1 second
  • 4. Quiz 1 1. Is the following an elementary operation? 2. Is the following an elementary operation?
  • 5. What is Time Complexity? Time complexity is a function to describe the approximate amount of operations an algorithm requires for the given input. We can calculate approximate execution time of code using time complexity and constraints.
  • 6. Big-O notation Big-O of an algorithm is a function to calculate the worst case time complexity of the algorithm. It is written as O(worst case time complexity) Big-O is used to calculate the approximate upper bound of the algorithm. It expresses how the run time of the algorithm grows relative to the input. More convenient and useful than other notations.
  • 7. Rules for Big-O notation • Should not have constants. • Should not have constant factors. • Only include the fastest growing function for each variable. • Can never be 0. Has to be atleast O(1) Example function: 2(N2) + 4N + 4(M3 + 5) + 10
  • 8. Quiz 2 1. (N+M) / K 2. N(N+1)/2 3. N2 + M(N2) + M2(N) + NM 4. N3/64 + 20N + (32NM)2
  • 9. Calculate Time Complexity of an Algorithm Time complexity usually depends on: • Loops • Recursion Time complexity of recursive algorithms will not be covered. Note: Usage of STL counts for time complexity
  • 10. Calculate Time Complexity of an Algorithm If there are nested loops, multiply the expected number of iterations of the loops Example:
  • 11. Quiz 3 Find the time complexity of the following code snippets in Big-O notation: 1. 2.
  • 13. Time Complexity based on Constraints Feasible Big-O Function Maximum N Example Algorithms O(𝑁!) 10 All permutations of a list O(𝑁3 ) 400 Multiplication of two matrices O(𝑁2) 5000 Square grid, bubble sort, insertion sort O(𝑁 𝑁) 105 Usually related to factoring O(𝑁𝑙𝑜𝑔𝑁) 106 Merge sort, binary search for N times O(𝑁) 107 Linear search, reversing an array, string comparison O( 𝑁) 1012 Factors of a number O(𝑙𝑜𝑔𝑁), O(1) 1018 Binary search, Constant time formulas
  • 14. Space Complexity Space complexity is similar to time complexity, except it measures the amount of memory. Any datatype that has constant memory takes O(1) space. Example: int, char, long long int, double, etc.
  • 15. Space Complexity Most problems have a memory limit of 256MB or ~2e8 bytes. Datatype No. of bytes char 1 int 4 float 4 long long int 8 double 8 long double 16
  • 16. Verdict of a solution • AC: Accepted • WA: Wrong Answer • TLE: Time Limit Exceeded • MLE: Memory Limit Exceeded • RE: Runtime Error – NZEC: Non Zero Exit Code – SIGSEGV: Usually due to out of bounds – SIGFPE: Usually division or modulo by 0 – SIGABRT: Due to assert statements
  • 17. Points to note: • Identify the variables that contribute to time complexity. • Just because constraints allow slower solutions, doesn’t mean there’s not a fast solution. For example, if N <= 1000, then both O(N2) and O(N) can pass. • Testcases matter, unless there’s a limit explicitly imposed in the constraints. • The constants and constant factors removed when calculating Big-O still matter.
  • 18. Problems to test understanding • https://codeforces.com/contest/1647/problem/A • https://codeforces.com/problemset/problem/1538/C • https://www.codechef.com/MARCH221D/problems/DISCUS • https://www.codechef.com/MARCH221D/problems/WORDLE • https://www.codechef.com/MARCH221D/problems/CHFDBT • https://codeforces.com/contest/1651/problem/B • https://codeforces.com/contest/1651/problem/A • https://codeforces.com/problemset/problem/919/B For more practice, try to figure out the time complexity for any random problem.
  • 19. Further Reading: • https://towardsdatascience.com/essential-programming- time-complexity-a95bb2608cac • https://www.youtube.com/watch?v=9TlHvipP5yA https://www.youtube.com/watch?v=9SgLBjXqwd4 https://www.youtube.com/watch?v=I0DTkS1LJ2k • https://adrianmejia.com/most-popular-algorithms-time- complexity-every-programmer-should-know-free-online- tutorial-course/ (advanced)