struct node{
    int value;
    node *left;
    node *right;
};
long sum(node *root, int a, int b) {
    if(root == NULL)
        return 0;
    if(root->value < a)
        return sum(root->right, a, b);
    if(root->value > b)
        return sum(root->left, a, b);
    return root->value + sum(root->right, a, b) + sum(root->left, a, b);
}
	 
 
	Am implementat de distractie rapid in c++, complexitatea este O(n).
 
	 
 
	Sunt curios daca exista solutie mai rapida.