CP164 Study Guide - Final Guide: Priority Queue, Emergency Department, Triage

25 views2 pages
14 Jun 2018
School
Course
Professor
Notes - The Priority Queue ADT
A priority queue is a collection of prioritized elements.
An emergency waiting room is a real-world example of a priority queue. Patients go
through triage (the process of determining the priority of patients' treatments based on the
severity of their condition) before being seen by a doctor. Those with the worst conditions
get highest priority. If two or more patients have equally bad conditions the patients are
seen in the order in which they arrived at the emergency waiting room.
The following diagram shows patients queueing for an emergency ward. The order they
enter the priority queue is irrelevant, and how they are organized once in the waiting area
is unimportant, what counts is the order in which they are served.
Priority Queue Methods
The basic queue methods are:
initialize: create an empty priority queue
insert: adds a new value to the priority queue
remove: removes and returns the value with the highest priority value in the priority
queue, if one exists. Values of equal priority are removed in the order in which they are
added to the queue.
peek: return a copy of the value with the highest priority value in the priority queue
without removing it, if one exists
is empty: returns True if the priority queue is empty, False otherwise
length: returns the number of items in the priority queue
Any implementation of a queue must define these methods.
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows half of the first page of the document.
Unlock all 2 pages and 3 million more documents.

Already have an account? Log in

Document Summary

A priority queue is a collection of prioritized elements. An emergency waiting room is a real-world example of a priority queue. Patients go through triage (the process of determining the priority of patients" treatments based on the severity of their condition) before being seen by a doctor. Those with the worst conditions get highest priority. If two or more patients have equally bad conditions the patients are seen in the order in which they arrived at the emergency waiting room. The following diagram shows patients queueing for an emergency ward. The order they enter the priority queue is irrelevant, and how they are organized once in the waiting area is unimportant, what counts is the order in which they are served. The basic queue methods are: initialize: create an empty priority queue insert: adds a new value to the priority queue remove: removes and returns the value with the highest priority value in the priority queue, if one exists.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers

Related Documents