Is there a way to tell whether a subroutine has runtime log(n)?

This question already has an answer here:

  • What does O(log n) mean exactly? 32 answers

  • When in each iteration we reduce the problem size be a factor of X , we can say that the problem is O(log n)

    Eg - Binary Search: in each iteration we reduce the problem size by factor of 2


    You can take as first example binary search. A explanation of the complexity of this algorithm can be taken from a related question how to calculate binary search complexity. It shown that the calculation of this type of complexity can be obtain from the recurrence.

    链接地址: http://www.djcxy.com/p/40026.html

    上一篇: 如何计算二进制搜索的复杂性

    下一篇: 有没有办法告诉子程序是否有运行时日志(n)?