Prob. 18, Sec. 2.3, in I.N. Herstein's TOPICS IN ALGEBRA, 2nd ed: For any $n > 2$ construct a non-abelian group of order $2n$ Here is Prob. 18, Sec. 2.3, in the book Topics in Algebra by I.N. Herstein, 2nd edition:

For any $n > 2$ construct a non-abelian group of order $2n$.

Herstein gives the following hint to this question: "imitate the relations in $S_3$ (permutation group of order $3$)".
I've already seen an answer to this problem using dihedral groups, but I still couldn't solve the question based on the hint.
Despite the fact I'm asking for a particular solution, please feel free to share different ways of doing it. It will be very interesting.
Thanks in advance.
 A: The hint was intended to point you toward dihedral groups, since $S_3$ is also a dihedral group of order $6$. By looking at the relations between elements and considering applying those same kinds of simple relations (half the elements are of order $2$, $r\cdot s^{-1}=s\cdot r$, etc...) to larger groups of order $2n$, you can uncover the dihedral groups.
A: Hint: If $H$ is a cyclic group of order $n>2$, then $h\mapsto h^{-1}$ is a nontrivial automorphism (more generally, this is true if $H$ is abelian and not of exponent $2$). Deduce that there is a nonabelian semidirect product $H\rtimes ({\bf Z}/2{\bf Z})$.
A: "Imitate the relations in $S_3$": To get the context of that hint, see a few pages earlier in the chapter, Example 2.2.3, where there is elaboration on how $S_3$ is generated by $\phi$ and $\psi$ with orders $2$ and $3$ respectively such that $\phi\psi=\psi^{-1}\phi$.  It is then explained that it follows that $e,\phi,\psi,\psi^2,\phi\psi$, and $\psi\phi$ are all of the elements of $S_3$.  To imitate this, you can change $3$ to $n$ and see what happens.  A more systematic way to organize the elements of $S_3$ that would make it easier to see how it will generalize may be $e,\psi,\psi^2,\phi,\phi\psi,\phi\psi^2$. 
A: I am reading "Topics in Algebra 2nd Edition" by I. N. Herstein.
This problem is Problem 18 on p.36.
I solved this problem as follows:

Let $\phi:=\begin{pmatrix}-1&0\\0&1\end{pmatrix}$.
Let $\psi:=\begin{pmatrix}\cos\frac{2\pi}{n}&-\sin\frac{2\pi}{n}\\\sin\frac{2\pi}{n}&\cos\frac{2\pi}{n}\end{pmatrix}$.
Let $D:=\{I_2,\psi,\psi^2,\dots,\psi^{n-1},\phi,\phi\cdot\psi,\phi\cdot\psi^2,\dots,\phi\cdot\psi^{n-1}\}$.
Obviously, $\psi^i\neq\psi^j$ for $0\leq i<j\leq n$.
Obviously, $\phi\psi^i\neq\phi\psi^j$ for $0\leq i<j\leq n$.
Since $\det\psi^i=1$ and $\det\phi\psi^j=-1$, $\psi^i\neq\phi\psi^j$ for $0\leq i<j\leq n$.
So, $\#D=2n$.
$\phi^2=I_2$.
$\psi^n=I_2$.
$\phi\cdot\psi=\begin{pmatrix}-1&0\\0&1\end{pmatrix}\cdot\begin{pmatrix}\cos\frac{2\pi}{n}&-\sin\frac{2\pi}{n}\\\sin\frac{2\pi}{n}&\cos\frac{2\pi}{n}\end{pmatrix}=\begin{pmatrix}-\cos\frac{2\pi}{n}&\sin\frac{2\pi}{n}\\\sin\frac{2\pi}{n}&\cos\frac{2\pi}{n}\end{pmatrix}$.
$\psi^{-1}\cdot\phi=\begin{pmatrix}\cos\frac{-2\pi}{n}&-\sin\frac{-2\pi}{n}\\\sin\frac{-2\pi}{n}&\cos\frac{-2\pi}{n}\end{pmatrix}\cdot\begin{pmatrix}-1&0\\0&1\end{pmatrix}=\begin{pmatrix}-\cos\frac{-2\pi}{n}&-\sin\frac{-2\pi}{n}\\-\sin\frac{-2\pi}{n}&\cos\frac{-2\pi}{n}\end{pmatrix}$.
So, $\phi\cdot\psi=\psi^{-1}\cdot\phi$.
$\phi\cdot\psi^{-1}=\phi\cdot\psi^{n-1}=(\phi\cdot\psi)\cdot\psi^{n-2}=\psi^{-1}\cdot(\phi\cdot\psi^{n-2})=\cdots=(\psi^{-1})^{n-1}\cdot\phi=\psi^n\cdot(\psi^{-1})^{n-1}\cdot\phi=\psi\cdot\phi.$
$\psi^i\cdot\phi\psi^j=\phi\psi^{-i}\psi^j=\phi\psi^{j-i}$.
Since $\psi^n=I_2$, we can write $\phi\psi^{j-i}=\phi\psi^k$, where $0\leq k<n$.
So, $\psi^i\cdot\phi\psi^j\in D$.
$\phi\psi^i\cdot\psi^j=\phi\psi^{i+j}$.
Since $\psi^n=I_2$, we can write $\phi\psi^{i+j}=\phi\psi^k$, where $0\leq k<n$.
So, $\phi\psi^i\cdot\psi^j\in D$.
$\psi^i\cdot\psi^j=\psi^{i+j}$.
Since $\psi^n=I_2$, we can write $\psi^i\cdot\psi^j=\psi^k$, where $0\leq k<n$.
$\phi\psi^i\cdot\phi\psi^j=\phi\phi\psi^{j-i}=\psi^{j-i}$.
Since $\psi^n=I_2$, we can write $\phi\psi^i\cdot\phi\psi^j=\psi^k$, where $0\leq k<n$.
So, $D$ is closed under the matrix multiplication.
$\psi^i\cdot\psi^{n-i}=I_2$.
$\phi\psi^i\cdot\phi\psi^i=I_2$.
So, any element of $D$ has its inverse.
Therefore, $D$ is a subgroup of $GL(2,\mathbb{R})$.
$\psi\cdot\phi=\phi\psi^{-1}=\phi\psi^{n-1}\neq\phi\psi$.
So, $D$ is non-abelian.

