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

  Runnig test cases on same piece of code

Why four people must waste their time looking for faults when one person can run test cases on same piece of code. How do you respond?

  Write english statement into a logical statement

Why is it important to change an English statement into a logical statement that follows the framework given by pseudo code and mathematical logic? Share examples and any further thoughts.

  Identification of the concept of a target audience

You are working on a new Web site for Cruzes, Inc. The Web site is aimed at providing travel information to consumers interested in cruises. When meeting with Jason, the marketing manager of Cruzes, Inc

  Use a random-number generator to pick each card

Your program must incorporate a two-dimensional array to represent the suit and the value of each card dealt to a player, keep track of which cards have been dealt to which player, and use a random-number generator to pick each card to be dealt to..

  Advantages and disadvantages of grassroots computing

Discuss how grassroots computing changes the way software is designed, developed, tested, and maintained in a typical organization. What are the advantages and disadvantages of grassroots computing?

  Modify the definition of avl tree and require

Suppose that we modify the definition of AVL tree and require that for every node, the difference between the heights of its left and right sub-trees is at most 2. Is the height of the tree still O(log n)? Prove your answer using induction.

  Steps for company browse the site using this url

The static IP address of the server is 192.168.45.200. What steps do you take so that each computer in  company can browse site by using this URL?

  What purposes do cpus, memory and i-o devices

What purposes do CPUs, memory and I-O devices individually serve in a computer system

  What is called a whitespace character

Given an int variable modelYear write a statement that assigns true to norecall if the value of modelYear does NOT fall within the two recall ranges and assigns false otherwise. Do not use an if statement in this exercise!

  Explain radio frequency identification technology

Write discussion of radio frequency identification (RFID) technology and Information Technology Infrastructure Library (ITIL) standards.

  Explain what happens when the reference to abstract class

Explain what happens when the reference to the abstract class X is used to execute method M1( ). X obj = new Y( ); obj.M1( );

  What are the problems with the horizontal and vertical

What are the problems with the ‘‘horizontal'' and ‘‘vertical'' solutions to the handling of multiple relationships as described in the chapter?

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