Are there any cases where you would prefer a higher big-O time complexity algorithm over the lower one?

后端 未结 22 1550
说谎
说谎 2020-11-28 01:06

Are there are any cases where you would prefer O(log n) time complexity to O(1) time complexity? Or O(n) to O(log n)?

22条回答
  •  囚心锁ツ
    2020-11-28 01:22

    My answer here Fast random weighted selection across all rows of a stochastic matrix is an example where an algorithm with complexity O(m) is faster than one with complexity O(log(m)), when m is not too big.

提交回复
热议问题