Firstly, your understanding of l , r and ppath correct.
pnodes and changed? work together as optimization: when you go up , if changed? is false, you are pushing the node out of pnodes, and not rebuilding it from the current node and to the left and the lists of right siblings.
Regarding the use of the vector for l and the list for r . Once again about the cost of recovering a node. Uete's paper has (rev left) @ (t::right) , which is O (nleft), where nleft is the size on the left. In Clojure we have (concat l (cons node r)) , which is O (1) [1], because l , which is a vector, does not need the opposite (vectors in Clojure can be efficiently traversed in any direction, but can be added only on the right).
[1] ok this is O (1) only at the time of creation: nleft conses will be lazily allocated as the resulting sequence is consumed by further calculation.
cgrand
source share