Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Code in JAVA public interface Stack { /** * Returns the number of elements in the stack. * @return number of elements in the stack

Code in JAVA

public interface Stack { /** * Returns the number of elements in the stack. * @return number of elements in the stack */ int size();

/** * Tests whether the stack is empty. * @return true if the stack is empty, false otherwise */ boolean isEmpty();

/** * Inserts an element at the top of the stack. * @param e the element to be inserted */ void push(E e);

/** * Returns, but does not remove, the element at the top of the stack. * @return top element in the stack (or null if empty) */ E top();

/** * Removes and returns the top element from the stack. * @return element removed (or null if empty) */ E pop(); }

image text in transcribed

A palindrome is a word, phrase, or sentence that reads the same backwards as forwards (with punctuations ignored). For example, A man, a plan, a canal: Panama. is a palindrome. King, are you glad you are king? is not a palindrome Implement the generic Arraystack that we discussed in class and include a toString method. The Stack interface of our ADT is provided. Create a driver class that declares a Stack as an instance of Arraystack and use it to see if a word or phrase entered by the user is a palindrome. Refer to the algorithm for reversal that we discussed in class but do not use this generic method. Declare and use the stack in main. Display the result of the palindrome test. For example, Enter a word, phrase, or sentence: A man, a plan, a canal: Panama. is a palindrome

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

Expert Performance Indexing In SQL Server

Authors: Jason Strate, Grant Fritchey

2nd Edition

1484211189, 9781484211182

More Books

Students also viewed these Databases questions