big o - for loop running time analysis java -
For all of these I have to find out the time to run.
1.
for (int i = 0; i & lt; n; i + = 2) yoga ++; For 2
(int i = 1; i & lt; n; i * = 2) yoga ++ 3. For the
(for int i = 0; i & lt; n; i ++) (int j = 0; j and lt; n; j ++) yoga ++; 4. yoga ++ (int j = 0; j & lt; n; j ++) for
(int i = 0; i & lt; n; i ++) sum ++ // The above two ends one after the other, not the nested 5.
For (int i = 0; i & lt; 2 * n; i ++) yoga ++ 6
For (int i = 0; i & lt; n * n; i ++) Yoga ++; 7. (int j = 0; j & lt; n * n; J ++) for
(int i = 0; i & lt; n; i ++) + + +; 8. For (int i = 0; i & lt; n; i ++) (int j = 0; j & lt; 10000; j ++) plus ++;
For the first time I got the O (N) and the fourth one I got the O (N ^ 2). Are they right? And how do I make others? I'm really confused with the other.
The answer can be expressed in large o or large theta.
Michael Elkan