Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C code plz 2. A word is considered a palindrome if the reverse of the word is the same as the original word. For

In C code plz
image text in transcribed
image text in transcribed
2. A word is considered a palindrome if the reverse of the word is the same as the original word. For example: the word "test" is not a palindrome as its reverse "tset" is not the same as "test". On the other hand, the word "racecar" is a palindrome as its reverse is the same as "racecar". Some other examples of palindromes are "hannah", "level", "madam", and "yay." Write a function that will take a string in the parameter and returns 1 , if the string is a palindrome, otherwise returns 0 . You have to use stack operations during this process. (Credit isn't awarded for correctly solving the problem, but for utilizing the stack in doing so.) Assume the following stack definition and the functions already available to you. The stack will be extended automatically if it gets full (so you, don't have to worry about it). The top of the stack is controlled by your push and pop operation as usual stack operations. void initialize(stack* s); // initializes an empty stack. int push(stack* s, char value); //pushes the char value to the stack int isEmpty(stack* s); // Returns 1 if the stack is empty, 0 otherwise. char pop(stack* s); // pops and returns character at the top of the stack. char peek(stack* s); // returns character at the top of the stack. Note: pop and peek return 'I' if the stack s is empty. int isPalindrome ( char str) \{ struct stack s; initialize(\&s); int len = strlen(str)

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

Step: 3

blur-text-image

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

Intelligent Information And Database Systems Asian Conference Aciids 2012 Kaohsiung Taiwan March 2012 Proceedings Part 2 Lnai 7197

Authors: Jeng-Shyang Pan ,Shyi-Ming Chen ,Ngoc-Thanh Nguyen

2012th Edition

3642284892, 978-3642284892

More Books

Students also viewed these Databases questions