Please help in this ques bc i couldnot solve myself
Please Tell me how to solve it
Question is not difficult you can try this at you own
i am giving you a hint
HINT:
Traverse the tree in the inorder traversal. If the Binary search tree is traversed in inorder traversal the keys are traversed in increasing order. So while traversing the keys in the inorder traversal. If the key lies in the range print the key else skip the key.
now try to code this
if have any difficulty feel free to ask
The thing is that i understood the logic but is the vector given in preorder i am asking this
and also i can simply sort the preorder and can print the number of nodes between k1 and k2
Yes you can do that
but it will not be good
in question you have to solve it using trees
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.