You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I need to iterate over subsets of a tree, instead of the entire thing.
The solution should be more efficient than just reading all leaves and skipping those outside the range I'm interested in.
Solution Sketch
The current tree iterator implementation uses a stack of in-progress iterators that range over the internal nodes.
The logic is that the tree iterator will progress the top most iterator and keep adding iterators onto the stack until it gets to a leaf node, then yield.
Once a node iterator is exhausted, it is popped off the stack.
One method for implementing a ranged version of the tree iterator is to pre-processes the iterator by skipping nodes from the front and back until the keys are inside of the range requested.
The downside to this solution is that it could require potentially O(n) work just to create and setup the iterator.
Another method would be to perform 2 iterative searches for the start and end of the range, and create the node iterators along the way.
The text was updated successfully, but these errors were encountered:
Problem
Solution Sketch
The text was updated successfully, but these errors were encountered: