Project 13: Nearest Job Locator
Scientific Computing
Builds on these lessons
Current Task
Objective
A KDTree partitions space so nearest-neighbor queries run much faster than checking every point one by one.
Task: build a KDTree of job locations and query the nearest one to a candidate's position.
index.py
from scipy.spatial import KDTree
import numpy as np
job_locations = np.array([[0, 0], [5, 5], [10, 10], [2, 2]])
tree = KDTree(job_locations)
distance, index = tree.query([1, 1])
print(distance, index)
* Hint: Correct characters turn green, incorrect ones turn red.
Live Preview
🖼️
Verify your code to see the preview