I have this homework question I'm stuck on. I have no idea where to start for either questions. Any help is appreciated! Thank you

I have this homework question I'm stuck on. I have no idea where to start for either questions. Any help is appreciated! Thank you

Copyright © 2021 JogjaFile Inc.
The sample space is the set of sequences comprising $n$ H's and a terminating T for $n \in \mathbb{N}_+$, and with probability $0$ a non-terminating sequence of H's.
If the probability of the algorithm returning $0$ is $p(0)$ we observe that $$p(0)=\frac{1}{2} + \frac{1}{2}(1-p(0)).$$
That is with probability $1/2$ the first flip is a H and so a $0$ is returned after the first flip, and if that was not a head a zero is returned with probability $1-p(0)$.