Big O Notation with Absolute Value?

后端 未结 2 416
一生所求
一生所求 2021-01-13 23:41

I\'m going through some programming interview question books, and I\'ve seen reference to \"O(|A|)\" time complexity. I\'ve never seen this notation with the a

相关标签:
2条回答
  • 2021-01-13 23:43

    You will see this notation always when A is not a number.

    A could be many things, so |A| depends on the context. E.g.

    • A is a vector of a lattice, so |A| is the length of the vector.
    • A is an (maybe unknown) algorithm (e.g. an attacker to an encryption), then |A| could be the complexity of this algorithm or the length of the random bit vector this algorithm uses.
    • A is a set, then is |A| the number of elements in the set, as Kostub Deshmukh mentioned.

    There can be many more cases.

    0 讨论(0)
  • 2021-01-14 00:09

    In set theory notation |A| is the cardinality of set A, in other words the number of elements contained in set A.

    For Reference: http://www.mathsisfun.com/sets/symbols.html

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