title: Big Oh notation - push and pop
body: <p>I think I am starting to understand at least the theory behind big Oh notation, i.e. it is a way of measuring the rate at which the speed of a function grows.  In other words, big O quantifies an algorithm's efficiency.  But the implementation of it is something else.  </p>
  
  <p>For example, in the best case scenario push and pull operations will be O(1) because the number of steps it takes to remove from or add to the stack are going to be fixed.  Regardless of the value, the process will be the same.  </p>
  
  <p>I'm trying to envision how a sequence of events such as push and pop can degrade performance from O(1) to O(n^2).  If I have an array of n/2 capacity, n push and pop operations, and a dynamic array that doubles or halves its capacity when full or half full, how is it possible that the sequence in which these operations occur can affect the speed in which a program completes?  Since push and pop work on the top element of the stack, I'm having trouble seeing how efficiency goes from a constant to O(n^2).</p>
  
  <p>Thanks in advance.</p>