mercredi 1 juillet 2015

Algorithm complexity: if/else under for loop

I am wondering if in a situation like the following (an if/else statement under a for loop) the complexity would be O(n) or O(n^2):

for character in string:
    if character==something:
        do something
    else:
        do something else.

Thank you!

Aucun commentaire:

Enregistrer un commentaire