Let $N$ be set of natural numbers, then the function $f: N→ N$, defined by $f(x) =\left\{\begin{matrix}\frac{n+1}{2}&,\text{if n is odd }\\\frac{n}{2}&,\text{if n is even }\end{matrix}\right.$, is
Answer & explanation
Correct answer: option 2
The correct answer is Option (2) → surjective but not injective
Define $f:\mathbb{N}\to\mathbb{N}$ by
$\displaystyle f(n)=\begin{cases}\frac{n+1}{2},&\text{if $n$ is odd},\\[4pt]\frac{n}{2},&\text{if $n$ is even}.\end{cases}$
For any $k\in\mathbb{N}$ both $n=2k$ (even) and $n=2k-1$ (odd) give
$f(2k)=\frac{2k}{2}=k,\qquad f(2k-1)=\frac{2k-1+1}{2}=k$
Thus two distinct inputs map to the same output $\Rightarrow$ $f$ is not injective.
For surjectivity: for every $m\in\mathbb{N}$ choose $n=2m$; then $f(2m)=m$, so every natural number is attained $\Rightarrow$ $f$ is surjective.
Therefore $f$ is surjective but not injective.