6. Analyzing Constant Time: O(1)
An algorithm runs in Constant Time, O(1), if the time required to execute it does not change, regardless of the input size (N).
This is the fastest possible complexity.
Example: Accessing an Array Element
No matter if the array has 10 elements or 1 billion, accessing the first element takes exactly one operation.
python def get_first_element(arr): # This operation is O(1) return arr[0]
Or a simple calculation:
def add_numbers(a, b): # This is O(1) return a + b
Even if you have 10 separate O(1) operations, the complexity remains O(1) because they don't depend on the size N.