Deriving the Time Complexity / Big O of an Algorithm