jeudi 3 décembre 2015

Time Complexity: Nested 'if-then-else'

"IF-then-ELSE" statements have time complexity of O(n). If they are nested together, is it still O(n) or does it become O(n^2)?

For example:

IF (List == NULL)
{
    IF (item > 0)
    {
        //re-call recursive function
    }
}

ELSE
    return item;

Also, is that recursive function call a time complexity of O(log(n))?

Thanks!

Aucun commentaire:

Enregistrer un commentaire