Big O asymptotic analysis/Big O notation

Big O asymptotic analysis/Big O notation 

Big O is one of the most fundamental tools for computer scientists to analyse the cost of an algorithm. Big O notation is used to calculate the runtime of the best, worse and expected case scenario. Big O only cares about the worse case scenario. 

This is a way of comparing multiple solutions which solve the same problem, to find out which solution is the most efficient in terms of time and space complexity. For example they are multiple ways to drive to Liverpool football Club however lets choose the way that is quickest (time complexity) and is least stressful so it takes up less head space for the driver (space/memory complexity). 

Time Complexity 

How long does the algorithm take to complete?

In the worse case scenario how long will it take to complete this algorithm? 

The execution time of a task in relation to the number of steps required to complete it.


Example: Quick Sort

Worse case= O(N2) - the pivot keeps getting the highest value

Best case= O(N) - if all elements are equal the array will only be traversed once 

Expected case= O(N Log N)


Space Complexity 

How much space does this algorithm need for this computation?

In the worse case scenario how much space will it take to complete this algorithm?

Amortized Time Complexity
average time taken per operation, if you do many operations. ArrayList resizing example 




Comments

Popular posts from this blog

Basic Overview of Microsoft Azure?

Understanding the basics of REST API with HTTP and JSON