|Write program to determine if a given sentence is palindrome or not
User Array-based Stack, and Linked-based Queue in your program.
Write class Stack using array with the following attributes and methods:
Attribute array (items) of 100 char.
Attribute (top) of type integer.
Constructor (Stack), and initialize (top) to -1.
Method (empty), which returns true if the stack is empty.
Method (push), which takes a character value and push it into the stack.
Method (pop), which returns the last value in (Last-In-First-Out).
Class Node and class Queue:
Write class Node with two attributes; data of type character, and next of type Node. Write a set and get methods for each attribute.
Write class Queue using Linked List with the following attributes and methods:
Attributes (Front and Rear) of type Node.
Constructor (Queue), and initialize all attributes to Null.
Method (empty), which returns true if the queue is empty.
Method (insert), which takes a character value, create object of node, save the character in it, and insert it into the queue.
Method (remove), which returns the first value in (First-In-First-Out).
Palindrome Algorithm in Main:
Create a stack and a queue
Ask user to enter a string
Read string and store it in string s
set variable (pal) of bool to true
Repeat for each character in s:
push s[i] in stack
Insert s[i] in queue
Start new Loop, until stack is empty:
x = stack.pop();
y = queue.remove();
if ( x != y ) set (pal) to false and break from loop
Now, if pal is true then string is "Palindrome", else string is "NOT Palindrome!".