问题描述
我经常在这里谈论大O,它相互度量算法
I often here people talk about Big O which measures algorithms against each other
此度量是衡量时钟周期或空间需求。
Does this measure clock cycles or space requirements.
如果人们想根据内存使用情况对算法进行对比,
If people want to contrast algorithms based on memory usage what measure would they use
推荐答案
如果有人说该算法运行时间为O(n),他在谈论速度。如果有人说此算法在O(n)空间中运行,那么他在谈论内存。
If someone says "This algorithm runs in O(n) time", he's talking about speed. If someone says "This algorithm runs in O(n) space", he's talking about memory.
如果他只是说此算法为O(n),则通常谈论速度(尽管如果他在讨论记忆时说过,他可能是在谈论记忆)。
If he just says "This algorithm is O(n)", he's usually talking about speed (though if he says it during a discussion about memory, he's probably talking about memory).
如果您不确定某个人在谈论什么,问他。
If you're not sure which one someone's talking about, ask him.
这篇关于大O衡量内存需求还是只是速度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!