Friday, January 3, 2014

Efficient implementation of range search

Your current search code is simply ignoring the property which makes binary search trees efficient, that for a given node the left subtree contains only values that are less than or equal to the node's value and the right subtree contains only values that are greater than or equal to the node's value.


For example, if the search range is 8..12 and the root node value is 5 then you have no reason to search the left subtree of the root node.


No comments:

Post a Comment