Write a recursive function to print reverse of a given string.
skeeG rof skeeG
Explanation: Recursive function (reverse) takes string pointer (str) as input and calls itself with next location to passed pointer (str+1). Recursion continues this way, when pointer reaches ‘\0’, all functions accumulated in stack print char at passed location (str) and return one by one.
Time Complexity: O(n)
See Reverse a string for other methods to reverse string.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Print words of a string in reverse order
- Print reverse string after removing vowels
- Convert a String to an Integer using Recursion
- Product of nodes at k-th level in a tree represented as string using Recursion
- Program for length of a string using recursion
- Move all occurence of letter 'x' from the string s to the end using Recursion
- Print Strings In Reverse Dictionary Order Using Trie
- Create a new string by alternately combining the characters of two halves of the string in reverse
- Check if a given string is a Reverse Bitonic String or not
- Length of longest palindromic sub-string : Recursion
- Reverse string without using any temporary variable
- Reverse the Words of a String using Stack
- Digital Root of a given large integer using Recursion
- Print shortest path to print a string on screen
- Write a program to reverse an array or string
- Reverse a string without affecting special characters
- Different methods to reverse a string in C/C++
- Reverse vowels in a given string
- Reverse words in a given String in Java
- Reverse string in Python (5 different ways)