title: Understanding Cormen post office location solution
body: <p>The book "Introduction to algorithms" by Cormen has a question <strong>post office location problem</strong> in chap 9. </p>
  
  <blockquote>
    <p>We are given n points p1,p2,...pn with weights w1,w2,....wn. Find a point p(not necessarily one of the input points) that minimizes the sum wi*d(pi,p) where d(a,b) = distance between points a,b.</p>
  </blockquote>
  
  <p>Looking at the solution to the same , I understand that the <strong><em>weighed median</em></strong> would be the best solution for this problem.</p>
  
  <p>But I have some fundamental doubts about the actual coding part and the usage. </p>
  
  <ul>
  <li><p>If all elements have equal weight , then to find the weighed median, we find the point till which summation of all weights &lt; 1/2. How to extend it here ?</p></li>
  <li><p>Given a real scenario having say the number of letters to be delivered at various houses as the weights and we want to minimize the distance to be traveled by finding the location of the post office, x coordinates given ( assuming all houses are in 1 single dimension) , how would we actually go about it ?</p></li>
  </ul>
  
  <p>Could someone help me in clearing my doubts and understanding the problem.</p>
  
  <p>EDIT : </p>
  
  <p>I was also thinking about a very similar problem : There is a rectangular grid(2d) and different number of people at various places and all want to meet at 1 point (should definitely have integer coordinates) , then what difference would be there from the above problem and how would we solve it ?</p>