X1018: Copy Stack to a Queue

Use these two interfaces to solve this problem.

public interface QueueADT<E> {
  public void clear();
  public boolean enqueue(E it);
  public E dequeue();
  public E frontValue();
  public int numElements();
  public boolean isEmpty();
}

interface StackADT<E> {
  public void clear();
  public boolean push(E it);
  public E pop();
  public E topValue();
  public int numElements();
  public boolean isEmpty();
}

Write a method to remove all of the elements from the 'stack' (one by one) and add them to a queue. Create a new queue of type QueueArray<String>. If stack is null, then just return an empty queue. Otherwise, return a queue that contains all the elements that were popped off the stack. Make sure you use the interfaces above to solve the problem.

Your Answer:

Feedback

Your feedback will appear here when you check your answer.