CSE 116 Lecture Notes - Lecture 37: Priority Queue, Comparator
Document Summary
Creates fair & equal system to handle data: structure for element processing in order added. Limited favoring of processing certain elements: use & process elements at both ends of structure. Strict ordering of data using elements importance: can only access & process most important item requires comparing elements to provide ordering (use compareto(e oth) if comparable or compare(e o1, e o2) if comparator) Require comparable elements or comparator to order elements. Clicker question: null as priority queue element: no! Must see priority queue implementation: yes! null always valid element answer: b. Works in fifo order reprioritizing possible: no reordering possible. No set names, often (cid:449)ill adopt queue"s. Priorityqueue implements collection: size() & isempty() must be defined by classes. Access similar to queue, but based on priority: but not fifo; returns elements smallest to largest. Most important element returned by its methods: no implementation required: ordering is theoretical. Smaller elements more important (and thus processed before) than larger elements.