Q. Identify the base case(s) in the following recursive function:


def function(n) :

    if n == 0 :

        return 5

    elif n == 1 :

        return 8

    elif n > 0 :

        return function1(n-1) + function1(n-2)

    else:

        return -1



Answer =

Here base case are:

(i)
    if n == 0 :
        return 5

(ii)
    elif n == 1 :
        return 8

(iii)
    else:
        return -1

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post