Question: Write a Python class PQueue that implements a priority queue using an array list of PQElement 's. In particular, you need to implement 5

Write a Python class PQueue that implements a priority queue using an

Write a Python class PQueue that implements a priority queue using an array list of PQElement 's. In particular, you need to implement 5 functions: _init_: for creating an empty priority queue size: for returning the size of the priority queue enq: for enqueueing a new PQ-element in the priority queue deg for dequeueing from the priority queue the PQ-element with the greatest priority _str_: for printing the elements of the priority queue into a string, in order of decreasing priority Your function for dequeueing should have complexity (1). Test each of the functions on examples of your own making. For example, running: 1s = PQueue () A = [("D",7), ("S",5), ("A",0), ("G",4), ("0",8), ("P",3), ("A",-4), ("S", 1), ("S",-1), ("T",2), ("G",-2)] for x in A: ls.enq (PQElement(x[0],x[1])) print (1s) print(1s.deq(), ls) should give this printout: [('0', 8), ('D', 7), ('5', 5), ('G', 4), ('P', 3), ('T', 2), ('5', 1), ('A', 0), ('S', -1), ('G', -2), ('A', -4)] ('0', 8) [('D', 7), ('5', 5), ('G', 4), ('P', 3), ('T', 2), ('s', 1), ('A', 0), ('s', -1), ('G', -2), ('A', -4)]

Step by Step Solution

3.47 Rating (157 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

It seems like youre asking about components of a successful crisis communication strategy based on the multiple options provided Heres a breakdown of ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Algorithms Questions!