Solving the recurrence T(n) = T(n / 2) + O(1) using the Master Theorem? [closed]

大兔子大兔子 提交于 2020-04-11 18:44:25

问题


I'm trying to solve a recurrence relation to find out the complexity of an algorithm using the Master Theorem and its recurrences concepts, how can I prove that:

T(n) = T(n/2)+O(1)

is

T(n) = O(log(n)) ?

Any explanation would be apprecciated!!


回答1:


Your recurrence is

T(n) = T(n / 2) + O(1)

Since the Master Theorem works with recurrences of the form

T(n) = aT(n / b) + nc

In this case you have

  • a = 1
  • b = 2
  • c = 0

Since c = logba (since 0 = log2 1), you are in case two of the Master Theorem, which solves to Θ(nc log n) = Θ(n0 log n) = Θ(log n).

Hope this helps!



来源:https://stackoverflow.com/questions/16681198/solving-the-recurrence-tn-tn-2-o1-using-the-master-theorem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!