Expected number problem of buttons needed to be pressed:

119 Views Asked by At

Bob’s calculator has only four buttons: 1, 2, 3 and clear which clears the display. Bob starts with an empty display and randomly clicks buttons until only 123 remains on the display. What is the estimated number of buttons he must press?

I’m thinking that I should consider “clear” as 0 and find the probability of 0123 appearing. Not sure how to go from there

1

There are 1 best solutions below

1
On

Assuming a digit string of indefinite length, and equal probabilities of getting $0,1,2,3,$ we define the states to be $s,d,z,a,b,c\;$ representing , starting state, dead end (waiting for zero), $0,1, 12, 123 $ respectively, and $E_s, E_d, E_z, E_a, E_b, E_c$ the expected number of button presses from the respective states to get the desired $123$ on screen. We want to compute $E_s$, the expected number of button presses needed from the starting state to get $123$ on screen, and we get the step by step equations, (or should we say, "press by press" equations )

eg equation $(1)$ means that from starting state ($s$), one press takes you to $0$ with $Pr=\frac14$, to $1$ with $Pr= \frac14$, or to $2$ or $3$ which are dead ends with $Pr = \frac12$

$E_s = 1 + \frac14E_z + \frac14E_a + \frac12E_d \tag 1$

$E_d = 1 + \frac14E_z + \frac34E_d \tag2$

$E_z=1 + \frac14E_z + \frac14E_a +\frac12E_d \tag 3$

$E_a =1+ \frac14E_z + \frac14E_a + \frac14E_b + \frac14E_d \tag 4$

$E_b = 1 +\frac14E_z +\frac12E_d \tag 5$

[Eq $(5)$ means that with one press from state $b$, either we reach our goal of $123$ on screen or revert to state $z$ or state $d$]

Solving the set of linear equations, we get

Expected $\#$ of buttons pressed $\;\boxed {E_s = 188}$