February 8, 2014 Given a string, reverse it using stack. For example “GeeksQuiz” should be converted to “ziuQskeeG”. Following is simple algorithm to reverse a string using stack. 1) Create an empty stack. 2) One by one push all characters of string to stack. 3) One by one pop all characters from stack and put them back to string. Following is C program that implements above algorithm. // C program to reverse a string using stack #include
Read full article from Stack | Set 3 (Reverse a string using stack) | GeeksQuiz
No comments:
Post a Comment