Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
以下函数进行简单除法的 (a) 最坏情况、(b) 最佳情况和 (c) 平均情况复杂度是多少
while n>=1 do n=n DIV 2 end {while}
你会如何证明复杂性的合理性?
The function is O(log n), since it will require exactly floor(log2(n)) + 1 iterations.
O(log n)
floor(log2(n)) + 1