A Trick That Doesn't Work and a Trick That Does

from blog NULL BITMAP by Justin Jaffray, | ↗ original
Ancestry I came across a cool algorithm recently for being able to efficiently answer ancestor queries in a tree ("is x an ancestor of y"). The trick is to assign to each node in the tree an interval [x, y] such that for any node, its children's ranges are contained within its range. It's easy to construct such ranges by doing a depth-first...