title: Algorithm complexity - explanation of O(log n)?
body: <p>I'm fairly new to complexity measures, please bear with.</p>
  
  <p>I understand the following complexity examples:</p>
  
  <p>O(n) - Linear Time</p>
  
  <p>Example: </p>
  
  <pre><code>std::vector&lt;int&gt; MyV={1,4,6,2,9};
  std::for_each(MyV.begin(), MyV.end(), [](int e1, int e1){return e1&lt;e2;});
  //I.e. n of operations based on the number of elements
  </code></pre>
  
  <p>O(1) - Constant Time</p>
  
  <p>Example:</p>
  
  <pre><code>for(int i=5; i--;)
  {
    //Do Stuff
  }
  //i.e. n of operations will be 5
  </code></pre>
  
  <p>O(n2) - Quadratic Time</p>
  
  <p>Example:</p>
  
  <pre><code>std::vector&lt;int&gt; MyVec_A={1,2,3,4,5};
  std::vector&lt;int&gt; MyVec_B={1,2,3};
  for(int i=MyVec_A; i--;)
  {
    for(int x=MyVec_B; x--;)
    {
      //Do Stuff
    }
  }
  </code></pre>
  
  <p>Are the above example correct? </p>
  
  <p>If not, could you provide some pointers as to how I can correct the examples?</p>
  
  <p>I'm also unsure of Logarithmic time O(log n), an example would be really helpful?</p>