
And the correct answer here is O(2n*n²) and the reason why this is correct is as follows

so the first line here takes constant amount of times so that's not going to be relevant.

Now, this loop here lines 2 to 5 are executed 2n*, so the question is each time this interloop here

lines 3 to 5 is executed, how much time does that take.

So checking of the assignment is valid, takes O(2n²*), then if the assignment is valid,

we need an additional O(n)+O(1), so an additional O(n) time because this here is constant,

so we can ignore it.

So the maximum time that lines 3 to 5 take is O(n²)+O(n)+O(1),

so the largest growing term here is O(n²)so the interloop takes O(n²*) and that is executed 2n*.

So that's why the running time of Alice's algorithm is O(2n*n²),

and the good thing is that because we have our own notation, we could do this analysis

without actually concretely stating how all of these algorithm is programmed.

So as I hoped you see, it's quite a useful notation to have.