Time 计算此代码的时间复杂度

Time 计算此代码的时间复杂度,time,time-complexity,Time,Time Complexity,有人能解释一下我如何计算h3(最坏情况)的时间复杂度吗。。。 鉴于此代码: int g3(int n) { if (n <= 1) return 2; int goo = g3(n / 2); return goo * goo; //i have trouble with this line` } int h3(int n) { return g3(g3(n)); //trouble with this one too } intg3(intn){ 如果(ng3

有人能解释一下我如何计算h3(最坏情况)的时间复杂度吗。。。 鉴于此代码:

int g3(int n) {
  if (n <= 1)
    return 2;
  int goo = g3(n / 2);
  return goo * goo; //i have trouble with this line`
}

int h3(int n) {
  return g3(g3(n)); //trouble with this one too
}
intg3(intn){

如果(ng3有O(logn)复杂度,n被n的所有值除以2,结果是一个对数函数。h3有O(logn),这是因为复杂度取决于函数g3,而与返回值g(g(n))中的函数组成无关而n的值,关键是g函数的复杂度。算法需要使用n的所有值,并做一些对数运算,得到n*logn的复杂度,这只是整数乘法。你能告诉我时间复杂度是多少吗?我仍然使用treeok得到nlogn,我想我已经算出了,我得到了O of n(,f3的时间复杂度是logn和log(2^n)的组合)