当对所有n而言,O(1)比O(n)更快时,在O(1)上选择O(n)? [英] Choosing O(n) over O(1) when for all of n, O(1) is faster than O(n)?

查看:78
本文介绍了当对所有n而言,O(1)比O(n)更快时,在O(1)上选择O(n)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果对于所有n,O(1)都比O(n)快,那么我何时会选择O(n)算法而不是O(1)算法的示例

Example of when I would choose O(n) algorithm over O(1) algorithm if for all of n, O(1) is faster than O(n)

推荐答案

一个示例是O(1)算法消耗大量内存,而O(n)算法则没有.与性能相比,内存更重要.

One example is the O(1) algorithm consumes lots of memory while the O(n) one does not. And memory is more important for you compare to performance.

这篇关于当对所有n而言,O(1)比O(n)更快时,在O(1)上选择O(n)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆