title: Check the presence of a number in an array with binary search
body: <p>I have a test assessment that I need to do. There is one question that I have been having trouble with.</p>
  <p>I have an array of numbers and I need to find a way to find that number in the array, which I have partially done. The problem becomes in the next step of the project which is that it has to accommodate a million items.</p>
  <p>I believe this is binary search. How do I do a binary search or equivalent?</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;sys/resource.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  #include &lt;unistd.h&gt; 
  #include &lt;sys/types.h&gt;
  #include &lt;algorithm&gt;
  #include &lt;vector&gt;
  
  using namespace std;
  
  class Answer
  {
  public:
      static bool exists(int ints[], int size, int k)
      {
  
          for(int i=0; i&lt;size; i++){
  
              if(ints[i]&lt;k){
                  return true;
  
  
              }
          }
          return false;
      }
  };
  </code></pre>
  <p>The images below gives an idea of what I need and my code</p>
  <p><a href="https://i.stack.imgur.com/arVXR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/arVXR.png" alt="the question and my code so far" /></a></p>
  <p>What I need:</p>
  <p><a href="https://i.stack.imgur.com/mlAgt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mlAgt.png" alt="" /></a></p>