title: algorithm to calculate perimeter of unioned rectangles
body: <p>I'm trying to calculate the perimeter of the union of a n rectangles, of which I have the bottom left and top right points. Every rectangle sits on the x axis (bottom left corner of every rectangle is (x, 0)). I've been looking into different ways of doing this and it seems like the Sweep-Line algorithm is the best approach. I've looked at Graham Scan as well. I'm aiming for an O(n log n) algorithm. Honestly though I am lost in how to proceed, and I'm hoping someone here can do their best to dumb it down for me and try to help me understand exactly how to accomplish this. </p>
  
  <p>Some things I've gathered from the research I've done:</p>
  
  <p>We'll need to sort the points (I'm not sure the criteria in which we are sorting them). </p>
  
  <p>We will be dividing and conquering something (to achieve the O (log n)).</p>
  
  <p>We'll need to calculate intersections (What's the best way to do this?)</p>
  
  <p>We'll need some sort of data structure to hold the points (Binary tree perhaps?)</p>
  
  <p>I'll ultimately be implementing this algorithm in Java. </p>