Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using python 3, Implement the Bounded Queue and Circular Queue ADT as seen in class. The python implementations of these data structures are in the

Using python 3, Implement the Bounded Queue and Circular Queue ADT as seen in class. The python implementations of these data structures are in the lecture slides. Make sure you raise exceptions when peek()/dequeue() if the queue is empty. enqueue() if the queue is full . Compare the runtime of dequeue() method in Bounded Queue and Circular Queue. In bounded queue, once you dequeue an item, the remaining items in the list will be shifted left. But in circular queue, you just change the start pointer (index) when you dequeue. So in theory, dequeue in circular queue should be much faster than that in bounded queue. Write your code to justify whether this hypothesis is true or false. Here are the steps for this experiment: 1. Create two queues, one bounded queue and one circular queue. 2. Insert some items into each queue. 3. Use the code we give to count the runtime of dequeue() function in each queue. 4. Print the dequeue() runtime for each queue and the runtime difference on screen. Since the computer is very fast, you may need to use a quite large capacity value and insert enough items. When counting the dequeue() runtime, do not just count the runtime of one function call, count the total runtime of considerable (for example, 1000) function calls for each queue. Otherwise you may just see zeros of the runtime. HINT: How to measure the time interval: import time start = time.time() # The program you want to test end = time.time() time_interval = end - start

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning Databases With PostgreSQL From Novice To Professional

Authors: Richard Stones, Neil Matthew

2nd Edition

1590594789, 978-1590594780

More Books

Students also viewed these Databases questions

Question

What is an entity? Discuss.

Answered: 1 week ago

Question

1 2) y=x-2 2 X Ay 2 65-3-2-1 x y= 1/2x-2 y -2

Answered: 1 week ago

Question

5. Discuss the key roles for training professionals.

Answered: 1 week ago