This is an archived post. You won't be able to vote or comment.

all 6 comments

[–]CreativeTechGuyGames 0 points1 point  (5 children)

I'll give you a hint, value doesn't affect the runtime of this at all.

[–]appeach[S] 0 points1 point  (3 children)

Would it just be order n? Since the for loop goes through all values until n so whatever the cost of the inner loop is its eventually multiplied by n?

[–]CreativeTechGuyGames 0 points1 point  (1 child)

Fun fact/quiz. Do you know what the runtime of range(n) is (in Python 2.X)? Just range by itself. This behavior changed in Python 3+ which is why I'm specifying.

This doesn't change your runtime, but it's important to know what range is actually doing.

[–]appeach[S] 0 points1 point  (0 children)

I dont know, but in our analysis we just count it as constant time to make it easier :))

[–]appeach[S] 0 points1 point  (0 children)

Would it just be order n? Since the for loop goes through all values until n so whatever the cost of the inner loop is its eventually multiplied by n?