I'm studying for an exam and need to see if my answers for the following question is correct.
Give the bigO estimate for each code fragment in terms on n. method L has method signature void L(int n) & has execution time complexity of O(n). method C has method signature void C(int n) & has execution time complexity of O(1).
1.
while (n>0){
L(n);
n=n/2;
}
2.
if(a<b){
System.out.println(C(n) + L(n));
else { Sytem.out.println(C(n) - L(n)) }
3.
while(n>0){
C(n);
n = n/2;
}
I'm thinking for 1) O(nlogn), 2) O(n) and 3) O(logn). Not sure if i'm 100% correct though. Any help?