SUNY Geneseo Department of Computer Science


Some Uses of Priority Queues

{Date}

CSci 240, Spring 2007
Prof. Doug Baldwin

Return to List of Lectures

Previous Lecture

Misc

Lab 13 due tomorrow (Tuesday)

CSci end-of-semester mixer

SOFIs

Final exam

Questions?

Priority Queues

"Priority queue" is defined by interface

Frequently implemented as a heap, but that's not essential to being a priority queue

Relation between priority queue and heap is much like relation between dictionary and ordered tree

Some uses of priority queues

            Simulator
                // keep events in priority queue, by time 'til due
                q.addItem( first event )
                while ( ! q.isEmpty() ) {
                    e = q.retrieveByPriority()
                    process e, e.g.,
                        collect statistics
                        update simulated time
                        create subsidiary events
                            q.addItem( new Event(time) )
                        etc.

Prioritized scheduling

[Example of Constructive Solid Geometry]

        triangulate primitives
        insert triangles into a priority queue
        while queue not empty
            retrieve a triangle
            split it
            insert any sub-triangles into priority queue

[


(No More Lectures)