The product of 2*12 can be found in terms of 0*1, 2*2, and (0+2)*(1+2), or 2*3. These products are 0, 4, and 6, so the desired product is 0*100 + (6-0-4)*10 + 4 = 24.
The product of 43*21 can be found in terms of 4*2, 3*1, and (4+3)*(2+1), or 7*3. These products are 8, 3, and 21, so the desired product is 8*100 + (21-8-3)*10 + 3 = 903.
The product of 45*33 can be found in terms of 4*3, 5*3, and (4+5)*(3+3), or 9*6. These products are 12, 15, and 54, so the desired product is 12*100 + (54-12-15)*10 + 15 = 1485.
So the overall desired product is 24*10000 + (1485-24-903)*100 + 903 = 240000 + 55800 + 903 = 296703.
Letting n=3u, and t(n)=s(u), we have
s(u) = 3s(u-1) + 4, so
(E-3) = <4>, so
(E-3)(E-1) = <0>, and thus
s(u) = a3u + b, or t(n) = an + b
From the recurrence, we have t(1) = 0 and t(3) = 4, and from
0 = a1 + b and 4 = a3 + b, we can determine that a=2 and b=-2, so that
t(n) = 2n - 2.
To look at things another way, there is a version of the algorithm in which no element comparisons are made for n=1. Since no subproblem remains to be solved, this must be the base case, so the recurrence then describes the number of element comparisons for n>=1. Therefore the value of t(n) at n=0 is irrelevant -- indeed, when n=0 it's not clear that one can talk about a successful search.
Note that this value must be optimal, since there are 2n different bit strings in the sequence. A similar observation applies to the algorithm in the next problem. A sequence that minimizes the cost as defined in that problem is called a Grey code.
In particular, if A(k) is the cost of the the cost of the 2k operations on k switches, then the cost of the first 2k-1 operations (that is, of all operations except the one that returns to the initial position) must be A(k)-1. So the first 2(n-1)-1 operations on n switches have cost A(n-1)-1, the next has cost 1, the next 2(n-1)-1 operations have cost A(n-1)-1, and the last has cost 1. Therefore A(n) = A(n-1) - 1 + 1 + A(n-1) - 1 + 1 = 2A(n-1). This recurrence has solution A(n) = a2n, and since A(1) = 2, a=1. So the sequence given by the algorithm for n switches has cost 2n. As in the previous problem, this cost is clearly optimal.