Question: This Must be In Python 3. Will only Thumbs Up if all questions are answered. The goal of this lab is to practice writing code
This Must be In Python 3. Will only Thumbs Up if all questions are answered. The goal of this lab is to practice writing code using Exceptions, Bounded Queues, Circular Queues and Single Linked List. Question 1)
Q2) 
Compare the runtime of dequeue() methods in Bounded Queue and Circular Queue. In bounded queue, once you dequeue an item, the remaining items in the list will be shifted left. This happen because we are using the pop(index) method in the list class to dequeue. Therefore, the dequeue in Bounded Queue is O(n) However in Circular Queue, the front most item is accessed in the list by using the subscription operator and the head is incremented by 1. Therefore, the dequeue in a Circular Queue is O(1). So in theory, dequeue in Circular Queue should be much faster than the dequeue in a Bounded Queue. Write your code to justify whether this hypothesis is true or false. Here are the steps for this experiment: 1. Create a Circular Queue object and enqueue 100000 items in it. 2. Create a Bounded Queue object and enqueue 100000 items in it 3. Compute the time required to dequeue all items from the Circular Queue. 4. Compute the time required to dequeue all items from the Bounded Queue. Here is how to use the time module import time start time.time) # The statement(s) that you want to test end time.time) timeinterval = end - start - 5. Print the dequeue(0 runtime for each queue Please note : We need to enqueue many items in the Circular and Bounded Queue in order to get a reasonable run time for both queues. Here is the sample output: For Bounded Queue, the total runtime of dequeing 1eeeee is: 2.2983570098876953 For Circular Queue, the total runtime of dequeing 1eee00 is: 0.11895871162414551 Compare the runtime of dequeue() methods in Bounded Queue and Circular Queue. In bounded queue, once you dequeue an item, the remaining items in the list will be shifted left. This happen because we are using the pop(index) method in the list class to dequeue. Therefore, the dequeue in Bounded Queue is O(n) However in Circular Queue, the front most item is accessed in the list by using the subscription operator and the head is incremented by 1. Therefore, the dequeue in a Circular Queue is O(1). So in theory, dequeue in Circular Queue should be much faster than the dequeue in a Bounded Queue. Write your code to justify whether this hypothesis is true or false. Here are the steps for this experiment: 1. Create a Circular Queue object and enqueue 100000 items in it. 2. Create a Bounded Queue object and enqueue 100000 items in it 3. Compute the time required to dequeue all items from the Circular Queue. 4. Compute the time required to dequeue all items from the Bounded Queue. Here is how to use the time module import time start time.time) # The statement(s) that you want to test end time.time) timeinterval = end - start - 5. Print the dequeue(0 runtime for each queue Please note : We need to enqueue many items in the Circular and Bounded Queue in order to get a reasonable run time for both queues. Here is the sample output: For Bounded Queue, the total runtime of dequeing 1eeeee is: 2.2983570098876953 For Circular Queue, the total runtime of dequeing 1eee00 is: 0.11895871162414551
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
