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

  Methods and best practices for conducting a code review

Use the information in the web article Effective Code Reviews Without the Pain for methods and best practices for conducting a code review, and tips for conducting the review remotely

  Write a java program that will play connect four

Write a java program that will play connect four - Must be a simple program no applets, jframes.

  Need the build function.use recursion

Implement remaining function. Everything else is provided. Use given material to receive points. Implement remaining function. Everything else is provided. Use given material to receive points. Implement remaining function. Everything else is provide..

  App that allows the user to enter a series of numbers

Write an app that allows the user to enter a series of numbers and manipulate them. The app should provide users with the option of adding or multiplying the numbers.

  Determine values of the side of triangle

Enter 3 integers and determine if these 3 values make up the sides of a triangle. If any side is

  Example of a problematic programming situation or scenario

Suggest one (1) example of a problematic programming situation or scenario that the use or implementation of a sequence structure could resolve

  Write a static method to check the string

The max() method cannot read any input values, nor print any output values. All input and printing is done by the main() method that calls max().

  How are servlets and jsps deployed inside weblogic

How are Servlets and JSP's deployed inside WebLogic? In a Weblogic CMP EJB, how to obtain the maximum value in the specified database column? In WLQL is there something similar to MAX() function in SQL?

  Explain the difference between jdk and jre

Explain the difference between Java Development Toolkit (JDK) and Java Runtime Environment (JRE). Identify and correct the error(s) in the given code.

  Program that asks how many automobiles are to be described

Write a program that asks the user how many automobiles are to be described, and for each automobile it inputs the user's selection of make and color.

  Create an invoice class with four attributes

Create an Invoice class with 4 attributes: PartNumber (type int), PartDescription (type String), Quantity (type int), and Price (type double)

  You have to design and implement a simple and small email

helo i need your help in java assignment. i need solution asap. i have seen the same question on your website and even

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