Thursday, 20 November 2014

More Big Oh

Its time to get a bit more complicated with Big Oh.  In other words, lets actually try to apply the working definition of Big-Oh to proofs.  As a reminder here is the formal definition of Big-Oh as introduced in class.  That is,
  1. A function f(n) is O(g(n)) of a function g(n) if there exists  A∈\mathbb{N} and B∈ \mathbb R+ such that if n>B then f(n) ≤ Ag(n). This is what it means for a function f(n) to be in O(g(n)).
Now, I'll be the first to admit that the course has gotten considerably more challenging since the start.  Let me elaborate on this point.  Big-Oh proofs, as discussed in lecture, are rather simple.  The approach is systematic for most problems of this nature.  For instance, trying to show that 3n^2 + 2n + 5 ∈ O(n^2) is rather simple, similarly to the problem 7n^6 - 5n^4 + 2n^3  ∈ O(6n^8 - 4n^5 + 2n).  Now the disproving aspect can be a bit more challenging depending on the mathematical expressions involved.  I personally found difficulty in attempting to solve the Week 10 Tutorial problem 2.  The problem asked to prove 6n^5 - 4n^3 + 2n^2 ∉  O(5n^4 - 3n^2 + 1).  I was stuck on this problem for some time, as I could not find a suitable value of n to choose.  However, the Big-Oh proofs involving non polynomials gets even worse.  I understand L'Hopitals Rule, and the process by which we can determine which function grows faster.  The part that confuses me is the definition of the limit involving infinities.  These are areas I need to improve in quickly.  Here are my next steps:
  1. Review lecture notes covering Big-Oh of polynomials, non-polynomials, limits
  2. Work through the tutorial problems for week 10 again.
  3. Work through some of the extra practice problems linked on the course homepage.
  4. Post questions that further confuse me on Piazza. 



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.