can u please check my code if my approach is wrong please suggest a write approach to this problem.
Range XOR problem
@rohit_2425
https://ide.geeksforgeeks.org/hbBzO8PVHk
This is the updated code. You made some errors in the previous one. First one was that when you were inserting numbers, you were storing the indexes in the parent node and not in the child nodes. Please dry run the code and you will be able to understand the error. And secondly, please make a constructor in the node class so as to set the left and right to NULL. Third , when the bit comes out to one in the max xor function, and you go to the left in case the left is not NULL, you do not add (1 << j) to the answer. This is because you are not finding the max xor. You are looking for the element with which the max xor is attained. You add 1 << i in case left is NULL and you have to move towards the right.
If my explanation was able to answer your query, please mark the doubt as resolved.
In your updated code , shows two test cases wrong.