What is the expectation of number of words 'ab' What is the expectation of number of words 'ab'  in random 20 length phrase that use letters from $\left \{ a,b \right \}$?
There are $2^{20}$ words with length 20 over an alphabet with 2 letters...
 A: There are $19$ places in a $20$-letter phrase where "ab" could occur. In a random phrase, each place has probability $1/4$ of actually having an "ab" there. Let $X_1,X_2,\ldots,X_{19}$ be the indicator rvs for the events that "ab" occurs in the various positions. What is sought is the expectation of $X_1+\cdots+X_{19}$, which, by the linearity of expectations is $$ E[X_1+\cdots+X_{19}]=E[X_1]+\cdots +E[X_{19}] = \frac{19}4=4.75.$$
Note this calculation does not depend on the independence of the random variables $X_i$, which (as was pointed out in a since-deleted comment by DonThousand) are not independent. 
A: We generate the words like this:


*

*Color the space between consecutive letters blue if the first letter differ from the second letter and red if they are equal. Since there are $19$ spaces, there are $2^{19}$ possibilities.

*Choose either $a$ or $b$ as the first letter, $2$ possibilities. So in total there are $2^{20}$ words.


Now:


*

*Which space is blue and which is red is independent, means in total there are as much blue as red

*Total number of blue is the sum of words $ab$ and $ba$. Total number of red is the sum of words $aa$ and $bb$.

*Suppose a word has $x$ $ab$ and $y$ $ba$. We can invert the word i.e. switch all $a$ to $b$ and vice versa, to have $y$ $ab$ and $x$ $ba$. Means there are as many $ab$ as $ba$. Same goes for $aa$ and $bb$.


$E(aa)+E(ab)+E(ba)+E(bb)=4E(ab)=19$
$E(ab)=\frac{19}{4}$
