Solution
Suppose \(f(x_1) = f(x_2)\). Note that
if \(x_1\) is odd and \(x_2\) is even, then we will have
\[x_1 + 1 = x_2 - 1 \Rightarrow x_2 - x_1 =
2\]
which is impossible. Similarly, the possibility of \(x_1\) being even and \(x_2\) being odd can also be ruled out,
using the similar argument. Therefore, both \(x_1\) and \(x_2\) must be either odd or even. Suppose
both \(x_1\) and \(x_2\) are odd. Then
\[f(x_1) = f(x_2) \Rightarrow x_1 + 1 = x_2 +
1 \Rightarrow x_1 = x_2\]
Similarly, if both \(x_1\) and \(x_2\) are even, then also
\[f(x_1) = f(x_2) \Rightarrow x_1 - 1 = x_2 -
1 \Rightarrow x_1 = x_2\]
Thus, \(f\) is one-one.
Also, any odd number \(2r + 1\) in the
co-domain \(\mathbb{N}\) is the image
of \(2r + 2\) in the domain \(\mathbb{N}\) and any even number \(2r\) in the co-domain \(\mathbb{N}\) is the image of \(2r - 1\) in the domain \(\mathbb{N}\). Thus, \(f\) is onto.