Computer Science to describe the performance or complexity of an algorithm. ▪ It specifically gives an indication of how well an algorithm scales, it is not a measure of efficiency. ▪ Big O specifically describes the worst-case scenario, and can be used to describe the execution time required or the space used (e.g. in memory or on disk) by an algorithm
grow linearly and in direct proportion to the size of the input data set. ▪ Big O notation will always assume the upper limit where the algorithm will perform the maximum number of iterations. ▪ O(n) code
performance is directly proportional to the square of the size of the input data set. ▪ This is common with algorithms that involve nested iterations over the data set. Deeper nested iterations will result in O(n3), O(n4) etc. ▪ O(n2) code
programs can be analysed by counting the nested loops of the program. ▪ A single loop over n items yields f(n) = n ▪ A loop within a loop yields f(n) = n2 ▪ A loop within a loop within a loop yields f(n) = n3
you have nested loops, and the outer loop iterates i times and the inner loop iterates j times, the statements inside the inner loop will execute a total of i x j times. ▪ This is because the inner loop will iterate j times for each of the i iterations of the outer loop. ▪ This means that if both the outer and inner loop are dependent on the p roblem size n, the statements in the inner loop will be executed O(n2) times.