I’m still learning about complexity measurement using the Big O Notation, was wondering if I’m correct to say that following method’s complexity is O(n*log4n), where the “4” is a subscript.
public static void f(int n)
{
for (int i=n; i>0; i--)
{
int j = n;
while (j>0)
j = j/4;
}
}
Yes, You are correct, that the complexity of the function is
O(n*log_4(n))Log_4(n) = ln(n) / ln(4)andln(4)is a constant, so if Your function has complexityO(n*log_4(n))it is also true, that it has a complexity ofO(n*ln(n))