A Deno + TypeScript playground for exploring algorithmic complexity, performance characteristics, and type-safe API design.
deno task startAn interactive CLI lets you select which algorithms to benchmark, set iteration counts, and view results in a live-updating table.
| Algorithm | Complexity | Notes |
|---|---|---|
| Linear search | O(n) | Works on any array |
| Binary search | O(log n) | Requires SortedArray<T> (enforced by types) |
| Native search | O(n) | Delegates to Array.findIndex |
| Algorithm | Complexity | Stable | Mutates |
|---|---|---|---|
| Native sort | O(n log n) | Yes | No* |
| Merge sort | O(n log n) | Yes | No |
| Insertion sort | O(n²) | Yes | No |
| Selection sort | O(n²) | No | No |
*Wraps Array.sort (TimSort in V8) but copies the input first to avoid
mutation.
- Multiple dataset sizes per category (search: 10K–1M, sort: 1K–50K).
- JIT warmup phase before measurement.
- Per-iteration timing via
performance.now()with min/avg/max reporting. - Randomized input for sort, worst-case (last element) for search.
This project uses TypeScript as a design and modeling tool:
- Branded types —
SortedArray<T>andIndexencode domain invariants at the type level, making illegal states unrepresentable. - Generic algorithm interfaces —
SearchAlgorithm<T, A>andSortAlgorithm<T>define contracts that all implementations conform to. - Factory functions — each algorithm is a factory returning an interface implementation, keeping instantiation uniform.