Find the expected number of $0$'s and $1$'s before the sequence $01$ I have the following problem:

Let $X_1,X_2,...X_N$ be a sequence of independent Bernoulli random variables. Let $p\in (0,1)$ and $P(X_i=1)=p, P(X_i=0)=1-p.$ What is the expected value $T_{01}$, the number of $0$'s and $1$'s, before (and including) the sequence "$01$".

This is what I have tried to come up with so far:
Basically there are three possible "events" that I have to consider:

*

*The event that the first slot is a $1$, the next $k-1$ slots are $0$'s and the $k$-th
slot is a $1$. For example, the event could look like this:

$$\color{green}{1}\color{blue}{0000000}\color{red}{1}000$$


*The event that the first $k-1$ slots are $0$'s and the $k$-th slot is a $1$:
$$\color{blue}{0000000}\color{red}{1}001$$


*The event that the first $k-2$ slots are $1$'s the $k-1$ slot is a $0$ and the $k$-th slot is a $1$
$$\color{green}{111111111} \color{blue}{0}\color{red}{1}011$$
I know from this MIT OCW Lecture (Link) that the proabability mass function (PMF) for such an experiment is given by:
$$p_{Y_k}(t)=\begin{pmatrix}t-1 \\ k-1\end{pmatrix}p^k (1-p)^{t-k}$$
This gives the probability of $k$ events in $t$ time.
My question:
My problem comes from the fact that I don't want to find the arrival time of $k$ events. I am looking the expected value of a very specific event. The event $01$. Do I just find the probabilities of the three cases I listed above and multiply them together? Figuring out the possible cases seems like a very tedious and time consuming way to do it. How can I approach problems like this? Is there some "recipe" that I can follow that extends to similar problems such as finding $T_{101}$ (the expected numbers of $0's$ and $1's $ until the sequence $101$?
I want to add another example that I tried to solve based on the answers and the comments:
Question: Find the expected number of $0$'s and $1$'s before the sequence $11$. In other words find $E[T_{11}]$:
$$\begin{align}E[T_{11}]&=p\left(E[T_{11}] \space \lvert \space X_1=1 \right)+(1-p)\left( E[T_{11} \space \lvert \space X_1=0] \right) \\  \end{align}$$
For the first term: $$\begin{align} E[T_{11} \space \lvert \space X_1=1]&=p\left(E[T_{11} \space \lvert \space X_1=1, X_2=1] \right)+(1-p)\left(E[T_{11} \space \lvert \space X_1=1, X_2=0] \right) \\ &=\underbrace{2p}_{\text{Achieved $11$ in two trials}}+\underbrace{(1-p) (2+E[T_{11}])}_{\text{cycled back to starting state wasting two trials}} \end{align} $$
For the second term:
$$E[T_{11} \space \vert \space X_1=0]=\underbrace{1+E[T_{11} ]}_{\text{Cycled back to starting state but having wasted one trial}}$$
Combining the terms and solving for $E[T_{11} ]$:
$$\begin{align} &E[T_{11}]=p(2p+(1-p)(2+E[T_{11}]))+(1-p)(E[T_{11}]+1) \\[10pt] &\iff E[T_{11}]= 2p+p(1-p)E[T_{11}])+(1-p)E[T_11]+(1-p) \\[10pt] & \iff E[T_{11}]-p(1-p)E[T_{11}]-(1-p)E[T_{11}]=p+1 \\[10pt] &\iff E[T_{11}](1-p+p^2-1+p)=p+1 \\[10pt] & \iff E[T_{11}]=\boxed{\frac{p+1}{p^2}}\end{align}$$
Assuming the probability $p=\frac{1}{2}$
$$\implies E[T_{11}]=6$$
 A: You could try the following, based on finding a recurrence relation. You can write
$$\begin{align*}
\mathbb{E}[T_{01}] 
&= \mathbb{E}[T_{01}\mid X_1=1]\Pr[X_1=1]
+ \mathbb{E}[T_{01}\mid X_1=0]\Pr[X_1=0]\\
&= \frac{1}{2}\left(\mathbb{E}[T_{01}\mid X_1=1]
+ \mathbb{E}[T_{01}\mid X_1=0]\right)
\end{align*}$$
Now, you can show/check that $\mathbb{E}[T_{01}\mid X_1=1] = 1+\mathbb{E}[T_{01}]$. (Can you see why?) The other one is a bit more annoying, but similarly
$$\begin{align*}
\mathbb{E}[T_{01}\mid X_1=0] &= 
\frac{1}{2}\mathbb{E}[T_{01}\mid X_1=0,X_2=0] 
+ \frac{1}{2}\mathbb{E}[T_{01}\mid X_1=0,X_2=1] \\
&=  \frac{1}{2}(1+\mathbb{E}[T_{01}\mid X_1=0])
+ \frac{1}{2}\cdot 2\\
&=  \frac{1}{2}\mathbb{E}[T_{01}\mid X_1=0])
+ \frac{3}{2}
\end{align*}$$
from which $\mathbb{E}[T_{01}\mid X_1=0]=3$. Putting the two together,
$$\begin{align*}
\mathbb{E}[T_{01}] 
&= \frac{1}{2}\left(1+\mathbb{E}[T_{01}] +3\right) = 2+\frac{1}{2}\mathbb{E}[T_{01}] 
\end{align*}$$
from which $\mathbb{E}[T_{01}]=4$.
A: From start (state a), one toss either takes you to $0$, or you are effectively back to start, waiting for a $0$
From $0$ (state b), one toss either takes you again to $0$, or you end having obtained $01$
$\displaylines{Thus\quad a = 1 + \frac12 b + \frac12 a,\;\\ b = 1 + \frac12 b}$
Solving, we get $a = 4$

PS
If probabilities of getting $0$ is p and that of getting $1$ is $(1-p)$, exactly the same process yields
$a = \dfrac{1}{p-p^2}, \;or\; \dfrac{1}{p(1-p)}$

PPS
Regarding "recipe" for, say, first $101$, you can follow the same process extended. Taking $p = \frac12$ to illustrate, and get a concrete answer.

*

*At start (state a), we are waiting for a $1$

*Having got $1$ (state b),we are waiting for a $0$

*Having got $10$ (state c), we are waiting for a $1$
We flit between the states until we reach the destination

*

*With one toss from a  we can either go to b or remain at a

*With one toss from b we can either go to c or remain at b

*With one toss from c we can end or go back to b
$\displaylines a = 1+\frac12 a + \frac12 b\\ b =1+ \frac12 c + \frac12 b\\c =1+ \frac12 b$
which yields $a = 8$
