The vantage-point tree has logarithmic height and its range and nearest neighbor searches are exact full
This proof shows: correctness.
We use the names of the pseudocode on the page. (U,d) is a metric space and P⊆U a finite set of n objects; obj(N) is the set of vantage points of the nodes in the subtree of N.
Lemma 1 (structure). BUILD(S) returns a tree whose nodes have the objects of S as vantage points, each exactly once, and each node N=(v,μ,in,out) satisfies d(v,x)≤μ for x∈obj(in) and d(v,x)≥μ for x∈obj(out).
Proof. By induction on ∣S∣. For S empty, line L1 returns nil. Otherwise line L2 takes v∈S, and the two lists of line L6 partition S′=S∖{v}, each shorter than S, so by induction the children hold their objects once each; with v at the root, S is covered once. If S′ is empty, line L4 returns a node with empty children, and the claim holds vacuously. Otherwise S′ is sorted by d(v,⋅) and μ=d(v,S′[m]); for i≤m, d(v,S′[i])≤μ, and for i>m, d(v,S′[i])≥μ. □
Lemma 2 (height). The tree built from n≥1 objects has height h(n)=⌊log2n⌋+1, counting nodes on a longest root-to-leaf path. BUILD makes at most n⋅h(n) evaluations.
Proof. The children have ⌈(n−1)/2⌉=⌊n/2⌋ and ⌊(n−1)/2⌋ objects. So h(1)=1 and h(n)=1+h(⌊n/2⌋) for n≥2, since h is nondecreasing by induction. For n≥2, ⌊log2⌊n/2⌋⌋=⌊log2n⌋−1: if 2j≤n<2j+1 then 2j−1≤⌊n/2⌋<2j. Induction gives h(n)=⌊log2n⌋+1. Line L3 makes ∣S∣−1 evaluations at a node with subtree set S, and the line L5 distance is already known. The subtree sets of the nodes at one depth are disjoint, so each depth costs at most n evaluations, and there are h(n) depths. □
Theorem 1 (range). RANGE(root,q,r,out) adds to out exactly the objects x∈P with d(q,x)≤r, each once.
Proof. We show by induction on the tree that RANGE(N,q,r,⋅) adds exactly {x∈obj(N):d(q,x)≤r}. For N = nil, line L7 adds nothing. Otherwise let t=d(q,v). Line L8 adds v if and only if d(q,v)≤r. If line L9 recurses, the induction hypothesis gives the answers in in. If it does not, then t−r>μ, and for each x∈obj(in), by the triangle inequality and Lemma 1, d(q,x)≥d(q,v)−d(v,x)≥t−μ>r, so in has no answer. If line L10 does not recurse, then μ−t>r, and for x∈obj(out), d(q,x)≥d(v,x)−d(q,v)≥μ−t>r. Lemma 1 says that v, obj(in) and obj(out) are disjoint, so nothing is added twice. □
Theorem 2 (nearest). If P is nonempty, after NEAREST(root,q) with τ=∞ at the start, b∈P and τ=d(q,b)=minx∈Pd(q,x).
Proof. Line L12 is the only line that changes (b,τ); it sets them to a visited object and its distance, and only when the distance is smaller. So at every moment τ=min of the distances of the visited objects, τ never increases, and b attains it. The root is visited, so b∈P at the end. Let τf be the final value. Suppose some x∈P has d(q,x)<τf. Then x was not visited, since otherwise τf≤d(q,x). So x lies in a subtree C of a visited node N that line L15 skipped at a moment when τ had a value τ0≥τf. If C=in, then t−τ0>μ and d(q,x)≥t−μ>τ0≥τf. If C=out, then t+τ0<μ and d(q,x)≥μ−t>τ0≥τf. Both contradict d(q,x)<τf. So τf is the least distance. ■