Learn basic concept of c , c++ and python programming in regularcodes.com

Spread the post

Check palindrome using stack

Write an efficient algorithm to, check given data are palindrome or not. In this post given a iterative solution using of stack.


program for palindrome string in c. Time complexity O(n) using stack.


Stack Areamaindata1 [0] A [1] B [2] C [3] B [4] A [5] \0data2 [0] A [1] B [2] B [3] C [4] A [5] D [6] \0top(pointer)palindromedata(pointer)index (int) =0result (int) =1top(pointer)popremove(pointer)top(pointer) Heap Areastruct Stackdata (char)= Anext (pointer)= NULLstruct Stackdata (char)= Bnext (pointer) struct Stackdata (char)= Cnext (pointer) struct Stackdata (char)= Bnext (pointer) struct Stackdata (char)= Anext (pointer)

Execution Process Try it Yourself

Spread the post

Recommended Posts: