I was tasked with finding a way to decide the language $A=\{0^k1^k \mid k\ge 0\}$ in $O(n\log n)$ time, and then to implement it on a deterministic Turing machine with one tape. Additionally, I was asked to check if it is possible to reduce the time from $O(n\log n)$ to $O(n)$ if using a determinstic Turing machine with two tapes (instead of one).
I am really stuck on it and don't know how to implement it. This is what I have so far:
First, we check that in the input word there are no zeros right of the ones. Then, for each zero in the input, we increase a binary counter and for the ones we do the same, creating a binary counter and increasing by one. if the counters are equal, accept, if not, reject. But i don't know how to implement it on a Turing machine, aside from the problem that if the counters of one and zero are far from the writing-reading head, then reaching it would take a lot of steps (time).
Regarding improving it to $O(n)$ time using a deterministic Turing machine with two heads: we go over with one head along the input string until we meet the first 1. then we count the number of one with one tape, and with the other the number of 0's. then we compare and accept if they are equal. So it is basically $k$ steps until the first 1, creating the counter, and counting each 1 $n$ times, then creating a counter with the second tape and comparing to the number of 0's in the beginning until the first one. So the total is $O(n)$. But how do I implement it on a Turing machine?