Alternating register automata on finite words and trees (Logical Methods in Computer Science, 2012)