What are the odds of flipping a coin 100 times and seeing HHHHT? What are the odds of flipping a coin 100 times and seeing exactly four consecutive heads? Any more than four heads in a row, such as "HHHHH" would not be considered a string of four consecutive heads. Seeing 10 sets of "HHHHT" would allow a max of 20 consecutive patterns. How would you expect to find the number of times an isolated string of exactly 4 heads in a row in $n$ coin flips?
 A: This seems to fall easily to linearity of expectation. Let $a_1,a_2\dots a_n$ be your sequence of outcomes.
Let $X_1$ be the indicator variable that $a_1,a_2,a_3,a_4=H$ and $a_5=T$
Let $X_{97}$ be the indicator variable that $a_{96}=T$ and $a_{97},a_{98},a_{99},a_{100}=H$
Finally, for $2\leq n \leq 96$ let $X_n$ be the indicator that $a_{n-1}=T,a_n,a_{n+1},a_{n+2},a_{n+3}=H,a_{n+4}=T$
The random variable you want is $\sum_{i=1}^{97} X_n$.
By linearity of expectation its expectation is $E[X_1]+95E[X_2]+E[X_{97}]=\frac{1}{32}+\frac{95}{64}+\frac{1}{32}=\frac{99}{64}$
A: For $i=1$ to $97$, let random variable $X_i$ be equal to $1$ if there is a string of HHHH that begins at $i$ and does not extend, and let $X_i=0$ otherwise. We want the expectation of $X_1+\cdots+X_{97}$. By the linearity of expectation, this is $E(X_1)+\cdots+E(X_{97})$.   
So we need only calculate the $\Pr(X_i)=1$. 
These are not all equal. If $i=1$ or $i=97$, we have $\Pr(X_i=1)=\frac{1}{32}$. For all the other $i$, we have $\Pr(X_i=1)=\frac{1}{64}$. That is because in all but "end" cases, the string of $4$ H must be flanked by T on both sides.
The required expectation is therefore $2\cdot \frac{1}{32}+95\cdot\frac{1}{64}$.
A: In any sequence of $100$ flips, “mark” each spot $HHHH$ occurs (and occurs not within a longer run of $H$’s) between the middle $H$’s. For example, the sequence $$HHTHHHTTTHHHHTHT\dots TTHHHHHTHTHHTTHHHH$$ would be marked $${HHTHHHTTTHH}^{\color{red}|\!}{HHTHT\dots TTHHHHHTHTHHTTHH}^{\color{red}|\!}{HH}^{}.$$
Among the $97$ positions where marks could occur (from after the first two flips to before the final two), a mark does appear in each of the $2^{\rm nd}$ through $96^{\rm th}$ ($95$ in all) of those spots (as $THH^{\color{red}|\!}HHT$) with probability $\frac{1}{2^6}$ (the chance the surrounding sequence of six flips is $THHHHT$). In the first and last positions, the probability is $\frac{1}{2^5}$ (the chance of $HH^{\color{red}|\!}HHT$ for position $1$ and $THH^{\color{red}|\!}HH$ for position $97$).
By the linearity of expectation, the expected number of marks is $95\cdot\frac1{2^6}+2\cdot\frac1{2^5}=\frac{99}{64}$.
[Added] It may be easier to focus on the $H$’s and $T$’s instead of the spaces between them, so another way to mark the runs-of-$4$ is to color in red the last $H$ of each run, like $$HHTHHHTTTHHH\color{red}HTHT\dots TTHHHHHTHTHHTTHHH\color{red}H.$$ The first three $H$’s are colored red with probability $0$, the fourth with probability $\frac{1}{2^5}$, the next $95$ with probability $\frac{1}{2^6}$, and the last with probability $\frac{1}{2^5}$, giving the same result.
