Fixed the bug and add a condition

should have been numItems instead of numItems - 1. Also, if the array is
full, we'll need to grow the array.