Growing Trees with Recursive Enums in Swift
summary
Builds a functional KD-tree using a recursive enum in Swift that avoids mutation and relies on Swift’s copy‑on‑write to stay fast. Implements median-split construction, nearest and k‑nearest queries and range search with expected O(log n) query time, parallelizes tree build to cut initialization time, and handles millions of points (benchmarks up to 5 million points). Includes a visual app that loads a star catalog (~120k stars in ~3s) and returns immediate nearest‑neighbor hits. Code is compact and working.
AI-written summary · about
chapters (26)
- 0:00Growing Trees with Recursive Enums in Swift
- 0:49credits
- 1:10contents
- 1:43recap: types in swift
- 3:09reference trees CS101
- 4:08enumerations in swift
- 14:47functional tree
- 15:24isn't that super inefficient
- 16:26copy on write
- 16:40break - space
- 16:56spatial data
- 18:57k-d tree
- 25:05KD Tree - Swift
- 26:15KD TreePoint protocol
- 27:28KD Tree - init
- 28:15KD Tree - inserting
- 29:46performance - NN
- 31:32range search
- 31:50performance - range
- 32:26aren't we forgetting something
- 33:44functional - parallelizable
- 34:50KD Tree - effort
- 37:12for looc.io
- 38:28recommender system
- 38:51further applications
- 40:26summary
