Search code examples
graphbig-onotation

Big O Notation with Absolute Value?


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 absolute value given.

Some research led me to Big O Cheatsheet that references this notation under the graphs section. The problem I'm researching is about partitioning an array, which isn't really a graph question (though I risk perhaps showing my ignorance with that statement).

Does |A| refer to the magnitude of the array, or otherwise number of elements, i.e. O(N)?


Solution

  • 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