I have difficulty determining the execution time of each step in an algorithm. I just can't understand the logic.
We all know prior to determining the Big O or Theta in an algorithm, we have to calculate the execution time of each step, then we calculate the order based on the execution time.
I find it easier to calculate the order than the Big O or the Theta, but my issue is with calculating the execution time.
Example:
for i=0 to **n**
dothisStep
The execution time of this is : (n+1) which makes it an order of O(N)--this is an easy one and I understood why--my problem is with the "harder ones". Sometimes I'm supposed to get n(n+1)/2, sometimes n(n+1), but I just can't understand how or why! What are the rules?