Data Structures – Interval Queries in Trie

The question is specifically about asking about range queries in a sorted data structure. I have a binary sort that represents a set of numbers in the binary form.

The numbers are initially given in tabular form: {2,1,5,6,4,7,3,8,9,10}

The test was constructed from the table above. Now, a range (l-r) and a number n are given. We need to find the maximum xor value between k and the elements in the range (l-r) of the array.


Entry: L = 3, R = 6, N = 5

Output: 6 (index = 4)

I've built the sort. I also know the little manipulation behind the search for maximum xor. I am unable to limit my search in the given range. Help kindly.