Another Example: Java Vectors
java.util.Vector
Intuitively, an expandable
array
Operations: addElement(),
elementAt(), setElementAt(),
others
addElement() increases the
size of the Vector
Implementation: uses arrays
with table doubling
When the array gets full,
allocate a new array, twice
as large, and copy all the
data to the new array
addElement() can take O(n)
worst-case time
Claim: the amortized time
per operation is O(1)
CS409 - Spring 2000
6