binary algorithm time complexity in the worst case code example Example: binary search time complexity Average case:O(log n) Best case:O(1)