I need to construct a TM that converts a number from binary notation to unary and calculate time complexity.
I have done the first part.
The idea is as follows:
binary number is decremented by 1 until it reaches 0. At each decrement an additional 1 is written on the left side.
e.g.
111 -> 1111111 111x (TM goes to the end of the binary number and writes x)
110x1
101x11
100x111
011x1111
010x11111
001x111111
000x1111111
1111111 (TM removes zeros and x; end)
And now comes the time complexity part. So far I have:
(1) TM will do $n$ (length of the binary number) steps to reach the end of the input word, additional 1 for writing x and 1 for moving back, so $n+2$;
(2) there are $2^{n}-1$ decrements, at that time TM will take in total $2 \times \frac{(2^{n}-1) (2^{n})}{2}$ steps on the left side, plus $2\times (2^{n}-1)$ for the x's. (no idea how many on the right side).
(3) TM will take $2n+1$ steps for removing unnecessary zeros and x at the end.
I don't know how to put this all together, plus some missing information in (2). Can anyone tell me if I'm computing correctly and how to proceed.
Any help will be much appreciated.