Geo*_*gan 1 complexity-theory big-o
我还在学习使用Big O Notation的复杂度测量,我想知道我是否正确地说下面的方法的复杂性是O(n*log4n),其中"4"是下标.
public static void f(int n)
{
for (int i=n; i>0; i--)
{
int j = n;
while (j>0)
j = j/4;
}
}
Run Code Online (Sandbox Code Playgroud)
是的,你是对的,功能的复杂性是 O(n*log_4(n))
Log_4(n) = ln(n) / ln(4)并且ln(4)是一个常数,所以如果你的函数具有复杂性,O(n*log_4(n))它也是如此,它具有复杂性O(n*ln(n))