CS 2336.004 Spring 2017
Assignment 3 – List, Stack and Queue
March 7th, 2017
Please include comments in all of your code. Describe what your function does, and describe
anything that is tricky or unclear.
Problem #1:
Write a simple Java method (C Function) that moves all of the contents of a stack onto a queue.
Use only the standard operations that apply to each ADT. (In other words, use push, pop, etc. for
a stack. Use enqueue, dequeue, etc. for a queue.)
Problem #2:
Write a simple method that moves all of the contents of a queue onto a stack. Use only the
standard operations that apply to each ADT.
Problem #3:
Write a simple method that moves all of the contents of one stack onto another stack without
changing the order. You may use the methods created in problems 1 and 2 if they help. You may
also use the standard operations of any of the ADTs we have studied thus far (lists, queues,
stacks).
Hint: Creating a temporary queue or stack might help.
Problem #4:
Start with a queue and an empty stack. Write a simple method that uses the stack to reverse the
order of the entries on the queue. (Your final answer should be stored on the queue.) You may
use the methods created in problems 1, 2, and 3 if they help. You may also use the standard
operations of any of the ADTs we have studied thus far (lists, queues, stacks).
Get Free Quote!
431 Experts Online