Determine if a string is a palindrome

Assignment Help Basic Computer Science
Reference no: EM13306347

Using the stack and queue class, determine if a string is a palindrome. A palindrome is a string (empty to many sentences) that reads the same forwards and backwards. Some simple palindromes are: an empty string, "mom", "racecar", "madam, I'm Adam!!" Remove any punctuation or spaces from the inputted string before testing it as a palindrome.

In main, create a char stack and a char queue. Read in a string and push each character of the string on to the stack and into the queue (enqueue). Call a method (isPalindrome) to determine if the string is a palindrome, using the following algorithm: while neither structure is empty, pop a character from the stack and dequeue a character from the queue. Compare the two characters to see if they are unequal (if unequal, return false). At the end of the process when the stack and queue are empty, return true.

Run the program 3 times - once with "abca", once with "madam, I'm Adam!!", and once with a string of your choice.

 

Reference no: EM13306347

Questions Cloud

Calculate the entropy change of the universe that occurs : The tank is insulated on the outside and the partition between the two sections is also an insulator. The partition can withstand a pressure differential across it of 400 kPa, before rupturing.
Determine what would be the total consolidation settlement : A normally consolidated clay layer in the field has a thickness of 3.2 m with an average effective stress of 70 kN/m^2. A laboratory consolidation test on the clay gave the following results: Pressure (kN/m^2)=100, 200 Void Ratio=0.905, 0.815
Determine the power of the source : The intensity I of light from an isotropic point source is determined as a function of distance r from the source. What is the power of the source
Compare and contrast aggressive and conservative asset : Compare and contrast aggressive and conservativeasset mix strategies.Address the issues of goals, liquidity, and risk.
Determine if a string is a palindrome : Using the stack and queue class, determine if a string is a palindrome. A palindrome is a string (empty to many sentences) that reads the same forwards and backwards.
Improve the contracting process : Identify someone in your life who would benefit from taking this course, and explain the reasons why and speculate on what technology might be able to do in 15 years to improve the contracting process.
Write a few lines relating the following concepts : If the real interest rate is less than the growth rate of output, explain why governments can run a deficit yet not have to worry about the size of their debt.
Print the list after each value is inserted into the list : Generate 10 random numbers between in the range of 25 to 50. Insert them into a list, keeping the list in order as each value is inserted. Print the list after each value is inserted into the list.
Create a new account for a new customer : You have been asked to write a program to organize accounts in a bank. Suppose all the accounts are stored in a data file called account.dat.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Which installation is suitable for customer tracking system

Which installation options are available for Customer Tracking System? Which would you suggest? How can you determine if implementation has been successful?

  Write algorithm to save few new phone numbers

write algorithm to save few new phone numbers in the address book of cell phone. algorithm should work even if there's only one new phone number or several new phone numbers to save. ke sure to handle the scene if the address book is full.

  You are a systems development consultant

You are a systems development consultant who has been approached by a client, a law firm, to develop an automated case tracking system. The first step is to negotiate the project scope

  Intelligent systems for health maintenance organization

Aacquiring a company in the health maintenance organization (HMO) field. DSS, ES, ESS, or intelligent systems can be used in such a situation.

  Write algorithm computing total flight time and distance

Write an algorithm for computing total flight time and the horizontal distance traveled by the cannon ball for the problem discussed in class?

  The value display style tells the browser not the element

The ____ value of the display style tells the browser not the display the element.

  How virtual memory relies on locality of reference principle

TLB entries are different than page table entries. Describehow they differ and why they differ. Virtual memory relies on a locality of reference principle. Describe.

  Transform g to an equivalent g'' that has no

Let G be a context free grammar with productions S->ABAC , A->aA|? , B->bB|? , C->d Transform G to an equivalent G' that has no ? productions and no unit productions

  How do i put three numbers in ascending order in ocaml

how do i put three numbers in ascending order in ocaml?

  Use java 5 to create a generic class drawingbox with a type

Use Java 5 to create a generic class DrawingBox with a type parameter that simulates drawing an item at random out of a box. This class could be used for simulating a random drawing.

  Create incident response policy covers development-response

Policy to reduce network down-time if future incidents happen. Create incident response policy which covers development of incident response team, disaster recovery process and business continuity planning.

  Achieving greater maturity that addresses funding priorities

Explains a set of recommendations for achieving greater maturity that addresses funding priorities. Explain a set of recommendations for achieving greater maturity that addresses key management capabilities.

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