Print BST keys in given range

I am facing the run error while submission. But it works perfectly fine in coding blocks ide. Here is the code link

hello @nikhil015
image

what if k1 and k2 are not present in the array .
in that case ur code will give wrong result

I found that my approach for printing elements in the range k1 and k2 is wrong. I couldn’t find another way how to print the elements in the given range

simply do inorder traversal of ur tree and then print all nodes that fall in range k1 …k2

I do that but it gives me WA

check this ->

Thanks it works, but how you think abut it?

in the code , we are doing inorder traversal only.

and while traversing .if we encounter any node whose value < k1 then simply we need to go right of it becuase in left we will even more less value.

similary if encounter any node whose value > k2 then simply we need to go to left of it becuae in right wr will get higher value.