\begin{algorithmic}
\STATE Input: Hierarchical clustering of n unlabeled points; batch size B
\STATE $P \leftarrow \lbrace root \rbrace$ (current pruning of the tree)
\STATE $L\lbrace root \rbrace \leftarrow 1$ (arbitrary starting label for root)
\FOR {time $t = 1$ until the budget runs out} 
\FOR {$i =1 $ to $ B$} 
		\STATE $v \leftarrow select(p)$ \\
		\STATE Pick a random point z from subtree $T_v$ \\
		\STATE Query z's label l \\
		\STATE Update empirical counts and probabilities $(n_u(t),p_{u,l}(t))$ for all nodes u on path from z to v
	\ENDFOR
	\STATE In a bottom-up pass of T, update A and compute scores s(u,t) for all nodes $u \in T$
	\STATE \FOR{each (selected) $v \in P$}
		\STATE Let (P',L') be the pruning and labeling of $T_v$ achieving scores s(v,t)
		\STATE $P \leftarrow (P \ \lbrace v \rbrace) \bigcup P'$
		\STATE $L(u) \leftarrow L'(u) for all u \in P'$
	\ENDFOR
\ENDFOR
\FOR {each cluster $v \in P$}
	\STATE Assign each point in $T_v$ the label \textit{L(v)}
\ENDFOR 
\end{algorithmic}