title: how can tree like data structure be implemented in this case
body: <p>I have a file like this </p>
  
  <pre><code>A 100 200
  A 120 220
  B 140 250
  </code></pre>
  
  <p>Another file is like this </p>
  
  <pre><code>A 130 210
  A 133 215
  B 180 270
  </code></pre>
  
  <p>Then I have to compare each row from first file to each row of second file and find which rows have intersecting co-ordinates </p>
  
  <p>Output will be like this</p>
  
  <pre><code>A 100 200 A 130 210
  A 100 200 A 133 215
  A 100 200 A 180 270
  </code></pre>
  
  <p>and it follows like that.</p>
  
  <p>In my code it code like this I get a first row from first file and compare with all row of second file.</p>
  
  <p>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.</p>