java - Big O Complexity for nested loop -
for (i = 0; < 2*n; += 2) { (j=n; j > i; j--) //some code yields o(1) }
i thought above yield n*log(n)
i've seen source n^2
complexity big oh. please explain me , how approach problems in future.
since big o upper bound, n * n <= n^2, resulting in o(n*2). answer right
Comments
Post a Comment