I have a file like this
A 100 200
A 120 220
B 140 250
Another file is like this
A 130 210
A 133 215
B 180 270
Then I have to compare each row from first file to each row of second file and find which rows have intersecting co-ordinates
Output will be like this
A 100 200 A 130 210
A 100 200 A 133 215
A 100 200 A 180 270
and it follows like that.
In my code it code like this I get a first row from first file and compare with all row of second file.
So I want to know how can I implement a tree like data structure to do this, so that complexity will be of log scale.