big oh notation question

i have always assumed that adding and removing to a vector was O(n). i was reading in an article and i am sorry i cannot remember where but it stated that it was possible to add and remove to a vector in O(1). can anyone briefly explain how that is possible?
[258 byte] By [devlinobrian] at [2007-11-20 11:45:23]
# 1 Re: big oh notation question
i have always assumed that adding and removing to a vector was O(n).Assuming you are taking about the Java Vector class, it is based on a object array, Object[], but is synchronized, so it's performance is generally acknowledged to be inferior to ArrayList. Whether it is still O(n) overall, the docs don't say, but since ArrayList is O(n), I'd guess it's of that order.

i was reading in an article and i am sorry i cannot remember where but it stated that it was possible to add and remove to a vector in O(1). can anyone briefly explain how that is possible?As far as I'm aware, there is only one legitimate way to add and remove from Vector, and that is to use the public API methods.

A little inaccuracy sometimes saves tons of explanation...
H.H. Munro
dlorde at 2007-11-10 2:13:57 >