Priority queue An example of how to use a priority queue in python. ***attached as a PDF because study monkey does not accept .py files ***

3 Pages
125 Views
Unlock Document

Department
Computer Science
Course
CSC148H1
Professor
Steve Engels
Semester
Winter

Description
import mediafrom oval import Ovalfrom line import Linefrom rectangle import Rectangleclass PriorityQueue Create a way to store the order in which the shapes are to be drawn onto the picturedef initself list Initialize the priorityqueue and then fill it with the contents oflist If list is not provided it defaults to emptyselfpriorityqueueif lenlist0if the list contains any shape objectsfor shape in list Get the current shapes priorityselfcurrentshapepriorityshapegetpriority If the currentshapepriority already exists as a key in the dictiona
More Less

Related notes for CSC148H1

Log In


OR

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Sign up

Join to view


OR

By registering, I agree to the Terms and Privacy Policies
Already have an account?
Just a few more details

So we can recommend you notes for your school.

Reset Password

Please enter below the email address you registered with and we will send you a link to reset your password.

Add your courses

Get notes from the top students in your class.


Submit