Program defines the QueueAsLinkedList constructor and destructor functions. In the case of the linked list implementation, it is not necessary to preallocate storage. The constructor simply initializes the list object as an empty list. The running time of the constructor is O(1).
Program: QueueAsLinkedList Class Constructor, Destructor and Purge Member Function Definitions
The QueueAsLinkedList destructor simply calls the Purge member function The Purge function deletes the contained objects one-by-one by traversing the linked list. Assuming that the running time of the destructor for each the contained objects is a constant, the total running time for the QueueAsLinkedList destructor is O(n), where is the number of items in the queue.