|
Data Structures and Algorithms
with Object-Oriented Design Patterns in Python |
Program
defines the QueueAsLinkedList
__init__ and purge methods.
In the case of the linked list implementation,
it is not necessary to preallocate storage.
The __init__ method simply initializes
the _list object as an empty list.
The running time of the __init__ method is O(1).
The purge method empties the queue by invoking the purge method provided by the LinkedList class and then sets the _count instance attribute to zero. Since a linked-list can be purged in constant time, the total running time for the purge method is O(1).