Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

this program is about identifying palindromes. A palindrome is a string that reads the same forward as backward. Some examples of palindromes are: Able was

image text in transcribed
image text in transcribed
this program is about identifying palindromes. A palindrome is a string that reads the same forward as backward. Some examples of palindromes are: "Able was I ere, I saw Elba." "Madam, I'm Adam." An algorithm to determine a string is a palindrome or not, is given below: Algorithm: Input: A string L, a temporary empty stack S, a temporary empty queue Q Output: Returns if L is palindrome or not 1. Set: P- first character in L 2. while (P -n') do 3. Push P onto S 4. Enqueue P to Q 5. Set: P next character in L 6. end while 7. Set: palindrome true 8. while (palindrome AND !Q.ISEmpty) do 9. M Pop from S 10. N Dequeue from Q 11. if (MI- N) then 12. Set: palindrome false 13. end if 14. end while 15. if (palindrome) then 16. Write "String is a palindrome" 17. else 18. Write "String is not a palindrome" 19. end if Notice that both Stack and Queue have been used in the algorithm. Your task for this assignment is to implement the algorithm by considering two cases: (i) lowercase and uppercase are treated the same way and (ii) only alphanumeric characters are considered; all others are discarded Input/Output Take an input string from keyboard and print the result on the screen. Input/Output Take an input string from keyboard and print the result on the screen. Sample input/output: Enter a string: Able was I ere, I saw Elba. This string is a palindrome Enter a string: My major is Biology This string is not a palindrome. Page 4 of 5 Enter a string: Eve This string is a palindrome. Upload in the URCourses The source code (Assignment2PartB.CPP)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Databases With Application To GIS

Authors: Philippe Rigaux, Michel Scholl, Agnès Voisard

1st Edition

1558605886, 978-1558605886

More Books

Students also viewed these Databases questions

Question

8 What personal development is elearning good at providing?

Answered: 1 week ago

Question

Explain Coulomb's law with an example

Answered: 1 week ago

Question

What is operating system?

Answered: 1 week ago

Question

What is Ohm's law and also tell about Snell's law?

Answered: 1 week ago

Question

2. Identify issues/causes for the apparent conflict.

Answered: 1 week ago

Question

3. What strategies might you use?

Answered: 1 week ago