
Dont know about recurrence based solution. Here is one solution i saw in contest and was able to submit to AC later in judge using Gaussian elimination
Let e[i] : e[0] .. e[n1] be expected number of times Target statement is executed if we start executing from statement i
e[i] = p* e[i1] + (1p) e[i2] // i1 and i2 are two branches, i2 = i+1 , next statement as per problem
= 1 + p* e[i1] + (1p) e[i2] // if i is target statement, we add 1 times of execution.Even after reaching target, it again gets executed further,
= 1.0 * e[i+1] // if i is start statement , next statement executes with 100% probability
= 0 // if i is End statement
Build a n x n set of equations and solve using Gaussian elimination. For eg above would become
1 e[i]  p e[i1]  (1p) e[i2] = 0
...
Then e[start] is the answer. 