I'm a java student who wants to get a better understanding of the big-O efficiency.
For this problem, it is assumed that doIt()
has an efficiency of O(n)
.
j=n;
while (j>0) {
doIt();
j = j / 2;
}
i = 1;
while (i < n) {
i = i * 2;
doIt();
}
What would be the big o efficiency of this algorithm, and why would it be that efficiency (such as O(n logn)
, O(n^2)
, O(n^2 logn)
, etc.).