• 2
    O(1) can be worse than O(N) sometimes...
  • 0
    I suck at math, or remembering these concepts I once learned and never used again. Can I get an explainer?
  • 2
    Time complexity and how it scales.

    O(1) - constant time, meaning regardless of the size, the operation should take the same amount of time. ie reading an element from an array given an offset.

    O(log n) - a binary tree with n elements should always have a depth of log n, therefore a lookup takes at most log n.

    O(n) - might require iterating through every element, like uppercaseing a string.

    O(N!) - for each element you need to operate through every remaining element.
    Examples of this are brute force travelling salesman, or sorting a list by checking every permutation of it if the next permutation is more sorted than the previous.
  • 1
    So, for a very small dataset, I still have a chance?
Add Comment