Can a phd thesis be in a different area than the master thesis?
A big part of the Theoretical Computer Science (language theory, automata theory, Turing machines and other computational devices) is actually a part of algebra so if you switch to TCS, you won't change the area too much. But in general changing the area when going from Masters to PhD is not a problem at all. People sometimes even have multiple PhDs in different totally disjoint areas.