Operations:
A queue is a simplification of a linked list. It works much like the line at Food Court. Elements can only be added on to the end (called "enqueueing"), and removed from the beginning. The implementation in ADT.h and ADT.cpp uses a circular doubly linked list with a sentinel as defined in ADTsentinelDLL.h and ADTsentinelDLL.cpp. Recall that a circular DLL with a sentinel looks like this:
|
The implementation says that enqueueing can only take place at the end and removing at the beginning, so a call to remove deletes the one at the beginning (John Linnel) and produces this:
|
And insertion only takes place at the end, so enqueue("Alfred
Yankovic")
produces:
|
queueTest.cpp is a simple driver for the queue class that you can use to exercise its functions and prove to yourself that this is really how it works.
Operations:
Just like a queue, but with the added ability to remove from the tail and add to the head. Think of a restaurant with a corrupt maitre d'. You can add yourself directly to the front of the line if you're willing to grease his palm a little. Or, you may decide that the wait is too long once you've gotten on the end of the line and decide to go someplace else. dequeueTest.cpp allows you to exercise a dequeue.
In all honesty, dequeues are not all that useful. But they make a Darned Fine Example for an application of linked lists.
And that's all I have to teach you about computer science.
The graduate students:
Undergrads:
And thanks to all of you. I hope you've enjoyed CS 5, and even if you didn't, I know that you learned a lot by taking the course.
If you liked CS 5, you should strongly consider taking CS 15. This winter is a good time to take it, and the CS department offers it every fall and winter term.
I have come to know many of you over the past 10 weeks, and it makes me sad to think that I won't see some of you again. So please, please, please stop by my office some time to say hello.
To Index Previous