Write a function called ispalindrome which uses a stack

Assignment Help JAVA Programming
Reference no: EM132088494

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.

Reference no: EM132088494

Questions Cloud

Production of an action potential : What would occur if voltage-regulated Na+ and K+ gates opened at the same time, rather than at different times, during the production of an action potential?
Create a matlab function named sumprod : Create a MATLAB function named sumprod . Prompts the user to enter the number of times N to repeat a loop.
Producing the female sex hormone : The layer of granulosa cells surrounding the oocyte within the ovary are responsible for producing the female sex hormone also known as?
Why does a lack of atp cause muscles : 1. Why does a lack of ATP cause muscles to stay relaxed or contracted?
Write a function called ispalindrome which uses a stack : Write a function called isPalindrome which uses a stack of characters to implement the above algorithm.
Prepare the journal entries in the records of white foam ltd : White Foam Ltd had received applications for 501,100 shares and 44,000 options by 10 May. Prepare the journal entries in the records of White Foam Ltd
Sliding filament theory : Put the statements below in order for the Sliding Filament Theory:
What types of threats do smart phones face : What types of threats do smart phones face? Are there any particular vulnerabilities to your type of device you have in your "system"
Describe the extensions of the dura mater : What symptoms will you, as the attending physician, observe, and how would you test her facial nerve? Describe the extensions of the dura mater.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd