Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 10: Define a MyQueue class. You need to implement a queue by creating push method for entering elements and pop type stored in your

image text in transcribed

Question 10: Define a MyQueue class. You need to implement a queue by creating push method for entering elements and pop type stored in your queue should be String. method for retrieving elements from an array. The data public class MyQueue Attributes: private int front, rear, size; I7 the index for firs, the index for last array and current s ize of your queue private String[] queueArray; /7 an array to save all elements in your queue private int maxSize; // the maximum size of your queue Methods: public void enqueue (String s); public String dequeue(); public boolean isEmpty(); public boolean isFull(); Question 11: In your Main class, build a reverseQueue method private static MyQueue removeRepeatedLetters (MyQueue queue); The reverseQueue method take a Myqueue object as input, and return a reversed queue. You need to use enqueue, dequeue to solve this problem. For example, Input: 14792 Output: 29741 Input: 3 3 412 Output: 21433 Question 12: Define a StackByQueue class. In this class, you need to implement a stack by using two queues you designed in question 10. You need to design and implement this class by yourself. The StackByQueue class need the following public methods public class StackByQueue Methods: public void push(String x); /7 push a string into stack public String pop) // pop out a string from the stack public String top) //return the top element in the stack public boolean isEmpty: I/return whether this stack is empty

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

Spomenik Monument Database

Authors: Donald Niebyl, FUEL, Damon Murray, Stephen Sorrell

1st Edition

0995745536, 978-0995745537

More Books

Students also viewed these Databases questions

Question

Discuss laws affecting collective bargaining.

Answered: 1 week ago