what is big O notation?
The way that describe the relationship between the runing time and the size of problem.
1- Method of calculating time complexity of algorithm.
1)hypothesis(假设法)
class solution{
int i = 0;
while(i <= n){
i = i * 2;
}
}
assuming that the executing time is t
t = 1, i = 2
t = 2, i = 4
t = n, i = 2^t
when 2 ^ t > n then the loop is stopped.
so ㏒n = t
t = logn