Ragmar R.
asked 09/20/14big O complexity
for(int i = 0; i < 1; i++)
for(int j = 0; j < 1; j++)
a = i;
what is the big O of this fragment code.
i said it will be O(n2), but my teacher said it is O(n)
for(int i = 0; i < n*n; i++)
for(int j = 0; j <= i; j++)
a = i;and for this one i said it is O(n3), but my teacher said it is O(n2)
is there any one who can help me understand that i am wrong, i can't admit it.
I just did it in an assumption that all arithmetic and logical operations will be computed onces and for each nested loop there will be an extra n.
More
1 Expert Answer

James G. answered 10/18/14
Tutor
5.0
(516)
Computer Science and Programming Tutor, Teacher, and Professional
We need more information to answer this, more details of the problem, O, etc. There is not enough context to answer which is why no one has answered.
Still looking for help? Get the right answer, fast.
Ask a question for free
Get a free answer to a quick problem.
Most questions answered within 4 hours.
OR
Find an Online Tutor Now
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.
Ragmar R.
09/23/14