Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in java Write a class named Palindrome.java and Write a method isPalindrome that takes an IntQueue as a parameter and that returns whether or not

in java

Write a class named Palindrome.java and Write a method isPalindrome that takes an IntQueue as a parameter and that returns whether or not the numbers in the queue represent a palindrome (true if they do, false otherwise). A sequence of numbers is considered a palindrome if it is the same in reverse order. For example, suppose a Queue called q stores this sequence of values:

front [3, 8, 17, 9, 17, 8, 3] back

Then the following call:

isPalindrome(q)

should return true because this sequence is the same in reverse order. If the list had instead stored these values:

front [3, 8, 17, 9, 4, 17, 8, 3] back

the call on isPalindrome would instead return false because this sequence is not the same in reverse order (the 9 and 4 in the middle don't match).

The empty queue should be considered a palindrome. You may not make any assumptions about how many elements are in the queue and your method must restore the queue so that it stores the same sequence of values after the call as it did before.

The method header is specified as follows:

public static boolean isPalindrome(IntQueue q)

To test your program, click to select the PalindromeTester.class and Run JUnit button Note: class name, variable name, and method names MUST be the same as specified.

Given files (for help)

IntQueue.txt

public class IntQueue{ Integer[] arr; int numOfElements=0; int front=0; int rear=-1;

public IntQueue(int cap);

public void enqueue(Integer data); public Integer dequeue();

public boolean isFull();

public boolean isEmpty(); }

IntStack.txt

methods document:

public class IntStack{ Integer[] arr; int index=0;

public IntStack(int cap);

public void push(Integer data); public Integer pop(); public Integer top(); public boolean isFull();

public boolean isEmpty();

}

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

Rules In Database Systems Third International Workshop Rids 97 Sk Vde Sweden June 26 28 1997 Proceedings Lncs 1312

Authors: Andreas Geppert ,Mikael Berndtsson

1997th Edition

3540635165, 978-3540635161

More Books

Students also viewed these Databases questions

Question

List out some inventory management techniques.

Answered: 1 week ago

Question

Develop skills for building positive relationships.

Answered: 1 week ago

Question

Describe techniques for resolving conflicts.

Answered: 1 week ago

Question

Give feedback effectively and receive it appropriately.

Answered: 1 week ago