Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database Foundations Technology Fundamentals For IT Success

Authors: Bob Bryla

1st Edition

0782143725, 9780782143720

More Books

Students also viewed these Databases questions