please try to solve that questions.
I presume you know the theorem that if two sets are isomorphic then they have the same cardinality?
The function is an isomorphism between the two sets as you can easily show. Thus since is countably infinite so is the set 2 .
(If you don't have this theorem available, note that you can put the two sets in one to one correspondence using the above function and go from there.)
Frankly your definition might be a cleaner approach. The book rather confused me when going over this.