Python 3.1 Data Structure Queue Method (Function and Main program) Splits pq into other priority queue, with elements of pq moved alternately to pq1...
View the step-by-step solution to:

Question

Python 3.1 Data Structure Queue Method (Function and Main program)


Splits pq into other

priority queue, with elements of pq moved alternately to pq1 and pq2. If pq is odd in length then pq1 should should hold more element than pq2. pq is empty when the function is completes.Test it with a list of 10 random numbers. Then write another function to determine whether two given queue are identical.Entries q1 and q2 are compared and if all contents are identical and in the same order, returns true otherwise return False. 

Ex.  Output should look like [1,2,3,4,5,6,7,]         pq1= [1,3,5,7]  

pq2=[2,4]  

Sign up to view the entire interaction

Top Answer

Here is the answer... View the full answer

pythonpriority.txt

import Queue class Queue_priority: def __init__(self, quepriorities): self.queues = {} self.marker = Queue.Queue() self.quepriorities = quepriorities for p in quepriorities: self.queues[p] =...

Sign up to view the full answer

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question