Question: package hw4; import edu.princeton.cs.algs4.Stack; public class StringQueue { //You may NOT add any more fields to this class. private Stack stack1; private Stack stack2; /**

package hw4;

import edu.princeton.cs.algs4.Stack; public class StringQueue { //You may NOT add any more fields to this class. private Stack stack1; private Stack stack2;

/** * Initializes an empty queue. */ public StringQueue() { // TODO }

/** * Returns true if this queue is empty. * * @return {@code true} if this queue is empty; {@code false} otherwise */ public boolean isEmpty() { // TODO return false; }

/** * Returns the number of items in this queue. * * @return the number of items in this queue */ public int size() { // TODO return -1; }

/** * Adds the item to this queue. * * @param item the item to add */ public void enqueue(String item) { // TODO }

/** * Removes and returns the item on this queue that was least recently added. * FOR THIS ASSIGNMENT, YOU MAY ASSUME THAT DEQUEUE IS NEVER CALLED ON AN * EMPTY QUEUE. * * @return the item on this queue that was least recently added */ public String dequeue() { // TODO return null; } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!