Data Structures and Algorithms
with Object-Oriented Design Patterns in C# |
Program defines the methods EnqueueHead and DequeueHead. The latter is trivial to implement--it simply calls the Dequeue method inherited from the QueueAsLinkedList class.
The EnqueueHead method takes a single argument--the object to be added to the head of the deque. The method simply calls the LinkedList.prepend method. Since the running time for Prepend is O(1), the running time of EnqueueHead is also O(1).