[Skip to Body]
Primary:
[Front Door]
[Current]
[Glance]
-
[Honesty]
[On Teaching and Learning]
Groupings:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Outlines]
[Readings]
[Reference]
Misc:
[SamR]
[Java 1.5 API]
[Espresso]
[TAO of Java]
[CS152 2004F]
Back to Stacks and Their Implementation. On to Priority Queues.
Held: Friday, 11 November 2005
Summary: Today we consider another important linear structure, the queue. Queues implement a first-in, first-out policy.
Related Pages:
Due
Notes:
Overview:
put method in queues is called
enqueue and the get method is called
dequeue. The peek method is called
front.
put, the strategy is similar to that of stacks: Shove it on
the end. (We'll need to keep track of the end.)
get can be fairly simple: Keep track of
the index of the first non-returned element (and increment it after each
call to get.
value)
next)
+---+---+ | * | *---> N +-|-+---+ V
FRONT BACK +---+---+ +---+---+ +---+---+ | | *---> | | *---> ... --> | | / | +---+---+ +---+---+ +---+---+
FRONT BACK +---+---+ +---+---+ +---+---+ | | *---> | | *---> ... --> | | / | +---+---+ +---+---+ +---+---+
FRONT BACK
+---+---+ +---+---+ +---+---+ +---+---+
| | *---> | | *---> ... --> | | *---> | * | / |
+---+---+ +---+---+ +---+---+ +-|-+---+
newval
get should be fairly simple.
FRONT BACK +---+---+ +---+---+ +---+---+ | * | *---> | | *---> ... --> | | / | +-|-+---+ +---+---+ +---+---+ val
val so that we can return it.
FRONT BACK
+---+---+ +---+---+ +---+---+
| * | / | | | *---> ... --> | | / |
+-|-+---+ +---+---+ +---+---+
val
CompareTo method.
Back to Stacks and Their Implementation. On to Priority Queues.
[Skip to Body]
Primary:
[Front Door]
[Current]
[Glance]
-
[Honesty]
[On Teaching and Learning]
Groupings:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Outlines]
[Readings]
[Reference]
Misc:
[SamR]
[Java 1.5 API]
[Espresso]
[TAO of Java]
[CS152 2004F]
Disclaimer:
I usually create these pages on the fly
, which means that I rarely
proofread them and they may contain bad grammar and incorrect details.
It also means that I tend to update them regularly (see the history for
more details). Feel free to contact me with any suggestions for changes.
This document was generated by
Siteweaver on Tue Dec 6 09:47:41 2005.
The source to the document was last modified on Thu Aug 25 16:15:09 2005.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS152/2005F/Outlines/outline.41.html.
You may wish to
validate this document's HTML
;
;
Check with Bobby