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

后端 未结 22 1555
说谎
说谎 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:43

    1. when redesigning a program, a procedure is found to be optimized with O(1) instead of O(lgN), but if it's not the bottleneck of this program, and it's hard to understand the O(1) alg. Then you would not have to use O(1) algorithm
    2. when O(1) needs much memory that you cannot supply, while the time of O(lgN) can be accepted.

提交回复
热议问题