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

What were the responsibilities of the communities during the Anglo-Saxon period?
income is constant, price of x has increased, no change in price of y
Tracy has a cell phone plan that provides 250 free minutes each month for a flat rate of $29.
Convert the angle radians to degrees
The following is a description of the conversion cycle of Central Production Limited: The conversion cycle of the company is triggered by a report from the ware
Parallel lines r and s are cut by two transversals, parallel lines t and u. Lines r and s are crossed by lines t and u to form 16 angles. Clockwise from top lef
The table below represents the total cost of leasing a car at the end each month. Month 1 -------- 3 -------- 8 -------- 1
Determine whether the results appear to have statistical​ significance, and also determine whether the results appear to have practical significance. In a study
13. Love is a emotion. learned primary personal fearful
What’s the color of the sky