title: Efficient way to get middle (median) of an std::set?
body: <p><code>std::set</code> is a sorted tree. It provides <code>begin</code> and <code>end</code> methods so I can get minimum and maximum and <code>lower_bound</code> and <code>upper_bound</code> for binary search. But what if I want to get iterator pointing to the middle element (or one of them if there are even number of elements there)?</p>
  
  <p>Is there an efficient way (<code>O(log(size))</code> not <code>O(size)</code>) to do that?</p>
  
  <pre><code>{1} =&gt; 1
  {1,2} =&gt; 1 or 2
  {1,2,3} =&gt; 2
  {1,2,3,4} =&gt; 2 or 3 (but in the same direction from middle as for {1,2})
  {1,312,10000,14000,152333} =&gt; 10000
  </code></pre>
  
  <p>PS: <a href="//ru.stackoverflow.com/q/746694/178988">Same question in Russian.</a></p>