\Theta (1): constant (any input) [00L2]

A \Theta (1) or constant time algorithm is one whose running time does not depend on the size of its input. If we have an algorithm that takes \Theta (1), we can obviously process arbitrary-sized inputs in less than one second.

Examples of \Theta (1) operations include:

  • Access an arbitrary index in an array
  • Push to or pop from the top of a stack
  • Add to or remove from the end of an extensible list (e.g. ArrayList in Java; Python lists)
  • Insert, update, or remove from a hash table (e.g. set + dictionaries in Python; HashSet/HashMap in Java)
  • Add to or remove from either end of a deque (double-ended queue)
  • Arithmetic (usually! sort of!)