COSC 2436 - Programming Fundamentals III Data Structures
Bob Comer, Professor of Computer Studies
Program 6 - Queue using a Circular Linked-List
Be sure to read through Chapter 8 of the textbook before starting this assignment.
Section 8.3 in the Nyhoff textbook discusses a linked-list implementation of a queue. Figure 8.3 has code for an implementation using a standard singly-linked list with two pointers - a pointer to the front element (myFront) and a pointer to the back element (myBack). Review this code to be sure that you understand how this implementation works.
Page 423 of your textbook discusses a modification to the linked-list implementation that uses a circular linked-list. In particular, the last paragraoh on page 423 suggests that this implementation only requires a single pointer to the back element (myBack).
Your assignment is to start with the code in Figure 8.3 of the textbook and modify it to use a circular linked-list with a single myBack pointer as described in the last paragraph on page 423 of the textbook.
I am not requiring you to write a copy constructor or overloaded assignment operator for your updated class. If you remove the prototypes for these functions from the class header file and the function definitions from the class implementation file, C++ will create a default copy constructor and assignment operator that will work incorrectly. To prevent a programmer from using these operations, I want you to do the following.
In the class header file, include prototypes for the copy constructor and asignment operator.
Instead of preconditions and postconditions, tell the client programmer that
the class has no copy constructor or assignment operator.
Queue(const Queue & original); // the Queue class has no copy constructor // Operations that require a copy constructor are not allowed const Queue & operator= (const Queue & rightHandSide); // the Queue class has no assignment operator // Assigning a Queue object to another Queue object is not allowed In the class implementation file,
do not include definitions for these functions.
Include brief documentation that the class does not have these functions.
//--- Queue class has no copy constructor // Queue::Queue(const Queue & original){} //--- Queue class has no assignment operator // const Queue & Queue::operator=(const Queue & rightHandSide){} |
Discussion/Questions
The following questions are designed to help you think about situations that you will need to identify in your circular linked-list. It would be a good idea to draw pictures of what the linked-list might look like to help you visualize what you are doing. These questions are NOT to be turned in. If you cannot answer any of these questions, it would be a good idea to discuss them with yoiur instructor or a tutor.
Hints
Return to Data Structures homepage
Return to ACC Homepage