Ask Question
26 June, 01:35

Write a recursive method to reverse a string. explain why you would not normally use recursion to solve this problem

+2
Answers (1)
  1. 26 June, 03:54
    0
    Here's a Python program:

    #!/usr/bin/python

    import sys

    def isPalindrome (string):

    if (len (string) < 2):

    return True

    elif (string[ 0 ] = = string [ - 1 ]):

    return (isPalindrome (string[ 1: - 1 ]))

    else:

    return False

    if (__name__ = = "__main__"):

    print isPalindrome (sys. argv[ 1 ])
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write a recursive method to reverse a string. explain why you would not normally use recursion to solve this problem ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers