Write an algorithm not code or solution only algorithm such as (step1, step2.....about.
1.How would you use a stack to verify whether a given string is a palindrome or not.
2. How would you check if a string is a palindrome or not, using queues and deques.
1. Algorithm:
Step 1: Start
Step 2: Store each character of input string in the stack, character by character. Element that is at the end of the string will be accessed first.
Step 3: Iterate over the Input string from first character and match it with the top character of the stack. If the element matches then remove it and move to the next character.
Step 4: If all the characters match and you are left with an empty stack then it's a pallindrome else it's not.
Step 5: Stop
Get Answers For Free
Most questions answered within 1 hours.