## Tracing Queues

Draw the state of the queue at the end of each of these blocks of code.

1.       my_queue = Queue()

for i in range(5):
my_queue.enqueue(i)

my_queue.dequeue()
my_queue.dequeue()

2.       my_queue = Queue()

for i in range(5):
my_queue.enqueue(i)

my_queue.dequeue()

for i in range(5, 10):
my_queue.enqueue(i)

my_queue.dequeue()
my_queue.dequeue()
my_queue.dequeue()

3.       my_queue = Queue()

for i in range(10):
if i % 2 == 0:
my_queue.enqueue(i)
else:
my_queue.dequeue()

4.       my_queue = Queue()

for i in range(10):
if i % 2 == 0:
my_queue.enqueue(i)
else:
removed_value = my_queue.dequeue()
my_queue.enqueue(removed_value)


5.       my_queue = Queue()

for i in range(10):
if i % 2 == 0:
my_queue.enqueue(i)
elif i % 3 == 0:
my_queue.dequeue()
else:
removed_value = my_queue.dequeue()
my_queue.enqueue(removed_value)

6.       my_queue = Queue()

for i in range(10):
my_queue.enqueue(i)

while my_queue.peek() != 5:
my_queue.enqueue(my_queue.dequeue())


7.       my_queue = Queue()

for i in range(10):
my_queue.enqueue(i)

while my_queue.peek() != 5:
if my_queue.peek() % 2 == 0:
my_queue.enqueue(my_queue.dequeue())
else:
my_queue.dequeue()


8.       my_queue = Queue()
temp_list = []
for i in range(10):
my_queue.enqueue(i)

for j in range(5):
temp_list.append(my_queue.dequeue())

for item in temp_list:
my_queue.enqueue(item)


### Submission

Bring this completed worksheet with you to the beginning of class on Wednesday.