1) Write a TM program to sort a nonempty string of A's and B. Assume the tape head starts on the leftmost character. For example if the tape contains BAABABB to start with, then when the machine halts AAABBBB will be left on the tape. Machine will be in the halt state (H) when done with tape head on the first nonblank character.
2) Recall, we showed that no FSA accepts the language 0n1n. Write a TM program that accepts this language. If the string is accepted the machine will halt in the accept state (A). Otherwise the machine will halt in the reject state (R). Note: the input string can be any sequence of 0's and 1's, e.g. 010101 (which would not be accepted) or 000111 (which would). Assume the input alphabet is just 0s and 1s. It's OK to erase the original string or modify it, as long at the correct state is reached when the machine halts.