Question: . a) Trace the following code segment, show the contents of the stack after each iteration of the for loop and the resulting stack: values
. a) Trace the following code segment, show the contents of the stack after each iteration of the for loop and the resulting stack:
values = Stack()
for i in range( 16 ) :
if i % 3 == 0 :
values.push( i )
elif i % 4 == 0 :
values.pop()
Trace the following code, show the contents of the queue after each iteration of the for loop and the resulting queue:
values = Queue()
for i in range( 16 ) :
if i % 3 == 0 :
values.enqueue( i )
elif i % 4 == 0 :
values.dequeue()
This is Python.
Thanks!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
