(Recursively Print a Queue Backwards) Write a method printQueueBackwards that recursively outputs the items in a linked list object in reverse order. Write a test program that cre- ates a list of integers and prints the list in reverse order.
What will be an ideal response?
```
# Recursively print a queue backwards.
from QueueModule import Queue
# recursively print queued items in reverse
def printQueueBackwards( queue ):
# base case - empty queue
if queue.isEmpty():
return
# dequeue item
item = queue.dequeue()
# call function on smaller queue
printQueueBackwards( queue )
print item,
queue = Queue()
for i in range( 1, 20 ):
queue.enqueue( i )
print "Queue:", queue
print "In reverse:",
printQueueBackwards( queue )
```
Queue: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
In reverse: 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
You might also like to view...
A(n) ________ is used to provide explanatory information about the macro or the action
A) condition B) command C) argument D) comment
Windows Server 2012 R2 has a group policy setting that renames the default administrator account to a value you specify. Intruders cannot simply look for ________ when attempting to crack your network
a. Admin b. Administrator c. Both Admin and Administrator d. None of the above
Which of the following are optional tasks when you're configuring Frame Relay? (Choose all that apply.)
a. Configure the LMI b. Configure static or dynamic address mapping c. Enable Frame Relay encapsulation on an interface d. Configure Frame Relay SVCs e. Configure Frame Relay traffic shaping
Which of the following media sanitization methods uses a program to write 1s and 0s on disk?
A. Formatting B. Deleting C. Degaussing D. Overwriting