Write a function called ispalindrome which uses a stack of


A palindrome is a word that reads the same way forward and backward, such as "dad" or "deed". You can determine if a word is a palindrome using a stack as follows:

1. Determine the length, n, of the word w.

2.Push the first n/2 characters of w, one at a time, onto a stack s. Each character pushed onto s is removed from w.

3. If n is odd, remove the first character of w.

4.If s is empty, then stop and declare w to be a palindrome.

5. Now, compare the top character in s with the the first letter of what remains in w.

If the letters are the same pop the top letter from s, remove the cooresponding letter from w and go back to step 4.

If the letters are not the same, then stop and declare w to be a non-palindrome.

Write a function called isPalindrome which uses a stack of characters to implement the above algorithm.

Note, isPalindrome takes a single string paramenter w and returns true if w is a palindrome and returns false otherwise.

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: Write a function called ispalindrome which uses a stack of
Reference No:- TGS02881951

Expected delivery within 24 Hours