title: Finding average case complexity with probability
body: <p>Lets say we have a string n, which can either be populated with "a"s or "b"s
  ex: n = "aaabbbab", "ababababab" and so on.
  and we define a function called </p>
  
  <pre><code>HalfA(n):
    count a = 0;
    for each i in n:
      if n == 'a'
          i++;
       if i &gt;= n.length/2
         return true 
    return false     
  </code></pre>
  
  <p>and if n has a uniform distribution, what is the average case complexity of halfA. Intuitively, I believe it to be len(n) but I'm not sure how to show this. And suppose a is more probable than b, and its not a uniform distribution, how do I calculate the average case then?</p>