Sorry, it's not always easy on a forum, I prefer explaining it with a whiteboard ^_^
The prefactor doesn't matter.
You can have 100000000 operations to add 5 elements and have 0(1)
And you can have 5 operations to add 5 elements and have O(n³)
It's only asymptotical behavior.
Suppose that you need K operations to perform a task with n data. How many operations do you need to perform the same task with 2n data ?
About the same number of operations -> O(1)
Two times the number of operations -> O
Four times the number of operations -> O(n²)
For example, you said adding 32 elements to an empty array is 260 operations.
For 64 elements, you would need 1044 operations.
32 x 2 = 64 and "260 x 2² = 1044". So it's O(n²)
Depends on what you're talking about...
When the array sized is multiplied by a constant factor (for example, doubled each time):
- Adding 1 element to an array containing n' elements is amortized O(1)
- Adding n elements to an empty array is O
- Adding n elements to an array containing n' elements is O
When the array size is increased by a constant factor (for example, add 2 spaces)
- Adding 1 element to an array containing n' elements is amortized O(n')
- Adding n elements to an empty array is O(n²)
- Adding n elements to an array containing n' elements is O(n.(n+n'))