Hint Assume the binary tree is properly balanced the depth o
Hint: Assume the binary tree is properly balanced (the depth of the tree T is O(log N)). For full credit, your algorithm should run in O(K+log N) average time, where K is the number of keys printed.
Solution
// Since the language is not specified, I\'m doing it in C++.
// Assumption: structure of the tree node:
/*
struct Node{
int data;
Node *left;
Node *right;
};
*/
void method(Node *root, int k1, int k2){
if(root == NULL) return;
method(root->left);
if(root->data >= k1 && root->data <= k2) cout << root->data << \" \";
method(root->right);
}
