Let us look at the following 2 cases:
We say a binary search implementation in a
sorted array
of sizen
has a time complexity of $O(\log n)$. In detail, $O(\log_{2} n)$ because binary search halves the input space with each iteration.In a recursive code block as below, We say that the time complexity is $O(3^n)$ as there will be exponential growth of branches in the order of 3 per iteration.
int recursive(int n){
if (n<=1){
return 1;
}
else{
return recursive(n-1) + recursive(n-2) + recursive(n-3);
}
}
Since Time Complexity talks about the behavior/trends of algorithms with respect to input size,
Can we say that the base component in the above cases is not crucial?
(logarithm's base component is 2 & exponential's base component is 3)
i.e., Can we just say their Time Complexity as $O(\log_{k} n)$ and $O(k^n)$ where $k$ is a constant?