Does Big O Measure Memory Requirments Or Just Speed?

前端 未结 8 1734
孤城傲影
孤城傲影 2021-02-18 16:08

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 contras

相关标签:
8条回答
  • 2021-02-18 16:29

    While normally algorithms compete on time, then I would normally assume that any O statement was time. However, it's perfectly valid to also compare space. O can be used for any measurement- we just normally use speed because it's normally the most important.

    0 讨论(0)
  • 2021-02-18 16:38

    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.

    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.

    0 讨论(0)
提交回复
热议问题