
270 A Practical Guide to Data Structures and Algorithms Using Java
17.4 Pe rformance Analysis
The constructor takes constant time when a doubly linked list is wrapped, and time proportional to
the capacity when an array-based representation is used. The asymptotic time complexity of the
other methods is as follows:
time
method complexity
constructor O(1) or O(n)
addFirst(o) O(1)
addLast(o) O(1)
getFirst() O(1)
getLast() O(1)
getSize() O(1)
isEmpty() O(1)
iterator() O(1)
removeFirst() O(1)
removeLast() O(1)
clear() O(n)
contains(o) O(n)
toString() O(n)
Since we have not wrapped the locator, the time complexity for any locator method is the same
as that for the