Question: 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

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, Im 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. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. Set: P = first character in L while (P != ) do Push P onto S Enqueue P to Q Set: P = next character in L end while Set: palindrome = true while (palindrome AND !Q.IsEmpty()) do M = Pop from S N = Dequeue from Q if (M != N) then Set: palindrome = false end if end while if (palindrome) then Write String is a palindrome else Write String is not a palindrome 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.

Enter a string: Eve. This string is a palindrome.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!