The following is exercise 8 (section 2.6) in Algebra by Hungerford:
Let $p$ be an odd prime. Prove that there are at most two nonabelian groups of order $p^3$. (One has generators $a,b$ satisying $|a| = p^2; |b|=p;b^{-1}ab = a^{1+p}$ and the other has generators $a,b,c$ satisfying $|a|=|b| = |c|= p;c = a^{-1}b^{-1}ab;ca=ac;cb=bc$)
I realize that there are many links online classifying groups of order $p^3$. However, most of the solutions I have seen have required several pages of work. Since this is just an exercise, I suspect there is a shorter solution. I have come up with the following:
We know that $Z(G) = p$ because $G$ is a $p$-group and if $|Z(G)| = p^2$ or $p^3$, then $G/Z(G)$ would be cyclic. Thus, $G$ would be abelian, contrary to hypothesis. So, let $c$ be a generator for $Z(G)$. Consider the quotient group $G/Z(G)$ which has order $p^2$. Hence, $G/Z(G) \cong \mathbb{Z}_p \times \mathbb{Z}_p$. Let $\overline{a},\overline{b}$ be generators for $G/Z(G)$ (the overlines denote passage to the quotient). Now, this means that every element in $G$ can be written as $a^ib^jc^k$ for $i,j,k \in \mathbb{Z}$. Since $c \in Z(G)$ we cannot have that $a,b$ commute (this is important later).
Notice that $\overline{a},\overline{b}$ both have order $p$ in $G/Z(G)$. Thus, $a^p,b^p \in Z(G)$. We consider cases of $a^p$ and $b^p$.
Case 1: both $a^p = b^p = 1$
Then, since $G/Z(G)$ is abelian, the commutator subgroup, $G'$, is contained in $Z(G)$ so that $|G'| = 1 $ or $p$. But, $|G'| = 1$ implies $G$ is abelian, contrary to hypothesis. So, $|G'| = p$ and consequently $G' = Z(G)$. Thus, since $a,b$ do not commute, $a^{-1}b^{-1}ab$ is nontrivial and $Z(G) = \langle a^{-1}b^{-1}ab\rangle$ (this is by the previous exercise where we showed that the commutator subgroup is generated by elements of this form). Thus, by possibly switching generators for $Z(G)$ this group satisfies the second pair of generators and relations in the question.
Case 2: $a^p \neq 1$ and $b^p = 1$ (or vice versa)
In this case $a^p$ is a nontrivial element in $Z(G)$ and since $Z(G)$ is cyclic of order $p$, $c = a^p$ and so $|a| = p^2$. This gives rise to the first pair of generators and relations.
It is here where I am stuck. These should be the only two, but I have not found a reason why we cannot have $a^p \neq 1$ and $b^p \neq 1$. How can I guarantee that this case does not occur (or gives one of the two cases above)? I assume this has something to do with the oddness of $p$, as I have not used this anywhere in the argument. Moreoever, any other suggestions or corrections on the current work would be greatly appreciated.
Thank You