(A) It is given that $f: W \rightarrow W$ is defined as:
$f(n) = \begin{cases} n-1 & \text{if } n \text{ is odd} \\ n+1 & \text{if } n \text{ is even} \end{cases}$
For one-one:
Let $f(n) = f(m)$.
If $n$ is odd and $m$ is even,then $n-1 = m+1 \Rightarrow n-m = 2$. This is impossible as the difference between an odd and an even number is always odd. Similarly,$n$ being even and $m$ being odd is impossible.
Therefore,$n$ and $m$ must have the same parity.
If both are odd,$n-1 = m-1 \Rightarrow n = m$.
If both are even,$n+1 = m+1 \Rightarrow n = m$.
Thus,$f$ is one-one.
For onto:
Any odd number $2r+1$ in the codomain is the image of $2r+2$ (which is even) or $2r$ (which is odd). Specifically,$f(2r+2) = 2r+1$ and $f(2r) = 2r+1$ is not the case here; rather,$f(2r+2) = 2r+3$ and $f(2r+1) = 2r$. Every $m \in W$ has a preimage. Thus,$f$ is onto.
Since $f$ is one-one and onto,it is invertible.
Let $g: W \rightarrow W$ be defined as $g(m) = \begin{cases} m+1 & \text{if } m \text{ is even} \\ m-1 & \text{if } m \text{ is odd} \end{cases}$.
We observe that $f(f(n)) = n$ for all $n \in W$.
If $n$ is odd,$f(n) = n-1$ (even),so $f(f(n)) = f(n-1) = (n-1)+1 = n$.
If $n$ is even,$f(n) = n+1$ (odd),so $f(f(n)) = f(n+1) = (n+1)-1 = n$.
Thus,$f \circ f = I_W$,which implies $f^{-1} = f$.