Ask Question
10 March, 01:24

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

+3
Answers (1)
  1. 10 March, 03:26
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers