Question: please writing for C++ code Part B [50] This program is about identifying palindromes. A palindrome is a string that reads the same forward as
please writing for C++ code
Part B [50] 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 Output: Returns if L is palindrome or not 1. Set: P first character in L 2. while (P !-1n') 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 (M !- 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. 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
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
