title: Time complexity of nested loops with if statement
body: <p>I am taking a class on advanced C++ but I am getting stumped trying to find the Big-Θ of nested for-loops that are locked behind if-statements. Unfortunately my professor (for some strange reason) just expects us to know this from a pre-req class (even though I took it at a different college with different course content) and will not take the time to teach me.</p>
  <p>I don't want anyone to solve my homework for me and I genuinely want to learn the concepts, so I created my own unique function down below. I just cannot wrap my head around whether this type of function is Θ(n) or Θ(n^2) given that the second loop only runs a few times. Any general explanation or maybe pointers in the right direction of how I can figure these types of problems out would be greatly appreciated :)</p>
  <p><strong>Note:</strong> Assume the variable n is a positive integer of any size.</p>
  <pre><code>int count = 20;
  for (int i = 0; i &lt; n; i ++) {
      if (i == count) {
          for (int j = 0; j &lt; count; j++) {
              // Some O(1) code
              // Maybe a print to console or something
          }
          count *= 2;
      }
  }
  </code></pre>