lean-bench

1.3. Complexity expressions🔗

The complexity expression on the right of => has type Nat → Nat. Pick whichever expression best models the algorithm:

Asymptotic

Lean expression

O(1)

1

O(n)

n

O(n log n)

n * Nat.log2 (n + 1)

O(n²)

n * n

O(n³)

n * n * n

O(2ⁿ)

2 ^ n

Nat.log2 is in core Lean. The + 1 in the n log n row guards against log2 0 = 0 producing a zero denominator in the ratio.