You got part (a) correct, think of a Cayley table, it consists of squares and for each square we can assign values from the set. Therefore, there are possible assignments. Exactly how you said!
To do part (b) again think of a Cayley table. Define the elements along the main diagnol i.e. define . Once you do that define the elements in the upper half of this diagnol. But if you defined (in the upper half) then (in the lower half) is simply a reflection through the main diagnol. Therefore, the Cayley table is completely determined once you defined the main diagnol and the upper half. There are squares on the diagnol and upper half therefore possibilities for the number of commutative mappings.
This is Mine 11,4th Post!!!