Let Define:
$$Q1=\{i^2\ mod\ p | 0\leq i<p\}$$ $$Q2=\{(-1)^i\cdot i^2\ mod\ p | 0\leq i<p\}$$ Let notice that for $p=47$ it can be shown that $|Q1|=24$ and $|Q2|=47$ but for other primary for example $p=5$ we get $|Q1|=|Q2|=3$. Explain the phenomenon and find a condition of prime number $p$ which gives us $|Q2|=p$.
Attempt: I tried to look of a small prime numbers like 7 and 11 that the phenomenon occurs without any idea or a clue why. More over I tried to look for some lemmas and sentences regarding Quadratic residues without any clue.
This depends on whether $p\equiv1\pmod4$. It is well known that $$\left(\frac{-1}p\right)=\begin{cases}-1&\text{if }p\equiv1\pmod4,\\1&\text{if }p\equiv3\pmod4.\end{cases}$$ Note that $$Q_2=\left\{(2k)^2\bmod p\mid0\le k\le\frac{p-1}2\right\}\bigcup\left\{-(2k+1)^2\bmod p\mid0\le k<\frac{p-1}2\right\},$$ denoted by $R_1\cup R_2$. Clearly $|R_1|=\frac{p+1}2$, for $(2i)^2\equiv(2j)^2\pmod p$ with $0\le i,j\le\frac{p-1}2$ only if $i=j$. Similarly we have $|R_2|=\frac{p-1}2$.
If $p\equiv1\pmod4$, then $-1\in R_1$, for $-1$ is a square modulo $p$. Thus $R_2\subset R_1$, and so $|Q_2|=\frac{p+1}2$.
If $p\equiv3\pmod4$, then $R_1\cap R_2$ is empty. The result then follows.