Question: 1. a) Hand execute the following code segment and show the contents of the resulting stack: values = Stack() for i in range( 16 )
1.
a) Hand execute the following code segment and show the contents of the resulting stack:
values = Stack()
for i in range( 16 ) :
if i % 3 == 0 :
values.push( i )
elif i % 4 == 0 :
values.pop()
b) Translate the following infix expression into postfix.
V * W * X + Y Z
c) Translate the following postfix expression into infix.
X Y Z + A B - * -
d) Hand execute the following code and show the contents of the resulting queue:
values = Queue()
for i in range ( 16 ) :
if i % 3 == 0 :
values.enqueue( i )
elif i % 4 == 0 :
values.dequeue()
e) Evaluate the following code segment which creates a singly linked list. Draw the resulting list, including the external pointers.
box = None
temp = None
for i in range( 4 ) :
if i % 3 != 0 :
temp = ListNode( i ) :
temp.next = box
box = temp
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
