E1nleannRachut E1nleannRachut
  • 09-12-2016
  • Computers and Technology
contestada

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

Respuesta :

rsmith6559
rsmith6559 rsmith6559
  • 11-12-2016
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 ] )


Answer Link

Otras preguntas

The product of 2.5 and x equals 12 in algebraic
Determine the number of solutions to each of the following equations. assume all zi are non negative intergers unless stated othewis.e (f) z1 z2 z3 1/2z4=11/2 g
Short tails (T) are dominant to long tails (t). What is the probability of a long-tailed mouse in the cross Tt x tt
find the intervals where the function is increasing and decreasing f(x)=x-e^(x)
Which statement can best be made based on information in the story? the lated a about aA. The narrator and his uncle have never ridden a horse before.B. The nar
•State how researching on this topic will help to improve/ change / stimulate / capacitate / make awareness / revitalise the methods of beef farming in your are
According to Kline, when listening appreciatively, "__________ encompasses many factors: the medium, the setting, the style and personality of the presenter, to
life expectancy difinition
Please help me on this math problem
СРОЧНО! ДАЮ 20 БАЛЛОВ