递归函数的编号执行

我有这种递归算法,T(n)是执行P(a,b)且n:= b-a的次数

int foo[] = ... // array of big enough size
function P(int a,int b) 
    if (a+1 < b) {
       int h = floor((a+b)/2)
       if foo[h] >= 0 then P(a,h)
       if foo[h] <= 0 then P(h,b)
    }
end function

如何计算T(1),T(2),T(3)和T(4)

onion_chan 回答:递归函数的编号执行

每次ab之间的距离(作为函数的输入)减少一半时,时间复杂度为Theta(log(b-a))

本文链接:https://www.f2er.com/2850324.html

大家都在问