Tuesday, 11 November 2014

Complexity and Algorithm Analysis

The past weeks we dived into algorithm complexity introducing an array of new concepts including: Big O, counting steps and worst case.  I will begin our discussion at Big O.  Typically Big O is used to compare how two algorithms scale up as the number of inputs increase.  For example, consider the following cases:
  • O(n)  --->  If the size of the input n increases, the runtime will increase linearly. 
  • O(log n) ---> If the size of the input n increases, the runtime will increase logarithmically. 
  •  O(1) ---> If the size of the input n increases, the runtime will remain constant (no change).
There are many other cases to consider, which we won't go into here.  If interested please check out the following link: \http://bigocheatsheet.com.
We also extended Big Oh to determine the complexity of the worst case runtime of the sorting algorithms we considered the previous week.  For instance, in the worst case bubble sort has a complexity of O(n**2), merge sort a complexity of O(n*log n), and insertion sort a complexity of O(n**2).  Fortunately for me, I found this content to be a review of the material presented in CSC108.    



No comments:

Post a Comment