mardi 21 septembre 2021

What is the Big O complexity of this recursive if function?

The code looks something like this:

int loop(int n){
    if(n == 0)
        return 0:
    else
        return loop(n-1) + loop(n-1):
}

I just can't understand if the return consists of two recursive loops does it just counts as double the time, ie 2n?

Aucun commentaire:

Enregistrer un commentaire