ts-algorithms · playground

Binary search · Dijkstra · LRU — same ideas as the library, runnable in the browser.

Sorted array — click Search to watch lo/mid/hi converge. O(log n) comparisons.

Complexity: O(log n) time · O(1) space. Each step halves the remaining window.

Toy weighted digraph A→F. Run Dijkstra from A and watch distances settle. O((V+E) log V) with a binary heap (here a simple scan).

Edges: A-B 4, A-C 2, B-C 1, B-D 5, C-D 8, C-E 10, D-E 2, D-F 6, E-F 3.

Capacity-3 LRU. Put moves a key to MRU; when full, the leftmost (LRU) is evicted. get/put are O(1) with a hash map + doubly linked list.

Complexity: O(1) get/put · O(capacity) space.

← portfolio