Data Structures and Algorithms with Object-Oriented Design Patterns in C#
next up previous contents index

The ``Head'' Operations

Program gif 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).


next up previous contents index

Bruno Copyright © 2001 by Bruno R. Preiss, P.Eng. All rights reserved.