What does O(log n) mean exactly?

后端 未结 30 3121
执念已碎
执念已碎 2020-11-22 01:19

I am learning about Big O Notation running times and amortized times. I understand the notion of O(n) linear time, meaning that the size of the input affects the g

30条回答
  •  南旧
    南旧 (楼主)
    2020-11-22 01:55

    Tree

    log x to base b = y is the inverse of b^y = x

    If you have an M-ary tree of depth d and size n, then:

    • traversing the whole tree ~ O(M^d) = O(n)

    • Walking a single path in the tree ~ O(d) = O(log n to base M)

提交回复
热议问题