java - Big O notation (Complexity) -
What's the big oops for this loop? - & gt; I think the loop is going to execute n times. But the inside work of the loop also n times correct? So can it make an O (N ^ 2) or do I combine them and this is a simple O (n)? I personally think that this is just O (n) because that is how many times a loop is executed, but I would like some explanation as to why or why not? As any explanation I have in my midterm. / code>
Think how often in the code executed by the loop. Each a [i] = b [i] is
a.length bar, which we will call on
n . So it is
o (n) .
Comments
Post a Comment