title: Time Complexity of Ternary Search Algorithm
body: <p>I have an assignment that wants me to write an ternary search algorithm and compute its time complexity afterwards. I was able to write an algorithm for it but I couldn't come up with any ideas how to compute its complexity. I think I didn't understand the concept of big-theta notation.</p>
  
  <p>Here is my code: It works like binary search but only divides the list into there pieces and continues the search like that.</p>
  
  <pre><code>    *some list which contains n increasingly-ordered integers;*
  
      int num;
  
      int min = 1;
      int max = n;
  
      int middle1 = (2*min+max)/3; 
      int middle2 = (min+2*max)/3;
  
      cin &gt;&gt; num;    //num is the number that is wanted to be found
  
      while (middle1 != middle2)
      {
          middle1 = (2*min+max)/3;
          middle2 = (min+2*max)/3;
  
          if(num &lt;= list[middle1])
              max = middle1;
          else if(num &gt;list[middle1] &amp;&amp; num &lt;= list[middle2])
              {
                      min= middle1; 
                      max = middle2;
              }
          else
              min = middle2;
      }
      if(num == list[max])
          cout &lt;&lt; "your number is found in the "&lt;&lt; max &lt;&lt;"th location\n";
      else
          cout &lt;&lt; "number cannot be found";
  </code></pre>
  
  <p>If you could explain how to determine its complexity in terms of big-theta notation, it would be very helpful for me.</p>