Classify all groups containing isomorphic copy of $\mathbb{Z}$ of index $2$. I have the following question:

Classify all groups $G$ containing an isomorphic copy of $\mathbb{Z}$ such that the copy has index $2$ in $G$

There are some candidates: $\mathbb{Z}\times\mathbb{Z}/2\mathbb{Z}$, $\mathbb{Z}$, and the infinite dihedral group $\mathcal{D}(\mathbb{Z})$. But how can we give a complete classification? Thanks!
 A: If your group is torsion-free, then it is isomorphic to $\mathbb{Z}$ (for a proof, see here).
If it has torsion, then it has an element of order $2$ (can you see why?).  This element generates a subgroup $H$ of order $2$, and your group is the semidirect product $\mathbb{Z}\rtimes H$.  This gives either a trivial action ($\mathbb{Z}\times\mathbb{Z}/2\mathbb{Z}$), or a non-trivial action (infinite dihedral group).
A: Hint. Let $G$ be a group in which $\mathbb{Z}$ is a subgroup of index $2$.
$\hspace{10pt}\text{S}{\small \text{TEP}}\text{ I}.\hspace{8pt}$ Prove that subgroups of index $2$ are necessarily 
normal.
$\hspace{10pt}\text{S}{\small \text{TEP}}\text{ II}.\hspace{5pt}$ This means that $G$ acts by automorphisms on $\mathbb{Z}$.  What are the automorphisms of $\mathbb{Z}$?
$\hspace{10pt}\text{S}{\small \text{TEP}}\text{ III}.\hspace{2pt}$ If $G=\mathbb{Z}K$, what are the options for $K$?  Relate this to the different options in $\text{II}$.
Note. Be careful in $\text{S}{\small \text{TEP}}\text{ III}$ to consider the case where the extension is nonsplit (that is, $G$ is not a semidirect product of the form $\mathbb{Z}\rtimes K$).  If you get stuck here, try constructing group presentations.
A: I try to see all possible multiplication table of $G$. Let $\mathbb{Z}\backsimeq <a>=H \leq G$  for some $a\in G$ and $G/H \backsimeq \mathbb{Z}/2\mathbb{Z}$. Take an element $b \in G-H$. Then $G$ is disjoint union of $H$ and $bH$. To fill the table, it is sufficent to know $ba^{i}ba^{j}$ and $a^{i}ba^{j}$ for any $a^{i}, a^{j} \in  H$. But since $ba^{i}ba^{j}=b^2(b^{-1}a^{i}b)a^{j}=b^2\phi_{b}(a^{i})a^{j}$ and $a^{i}ba^{j}=b(b^{-1}a^{i}b)a^{j}=b\phi_{b}(a^{i})a^{j}$ where $\phi_{b}\in Aut(H)$ is a conjugation by $b$, it is sufficient to know $\phi_{b}$ and $b^{2}$. Note that $Aut(H)=${$Id$, inversion}. Suppose $\phi_{b}=Id$. Then $G$ is abelian. Recall one of abelian candidate $\mathbb{Z}$ for $G$. So we should find an element $c\in G$ with $c^{2}=a$. We know $b^{2}=a^{k}$ for some $k\in \mathbb{Z}$. If $k$ is odd, then $b^{2}=a^{2n+1}$ i.e. $a=(ba^{-n})^{2}=c^{2}$. Now let $G$ be the disjoint union of $H$ and $cH$. Then we can fill the multiplication table of $G$ where $G\backsimeq \mathbb{Z}$ and $H\backsimeq 2\mathbb{Z}$. If $k$ is even, then  we expect to find an involution $d \in G$ because of other abelian candidate $\mathbb{Z}\times \mathbb{Z}/2\mathbb{Z}$. Again we know $b^{2}=a^{k}$ for some $k\in \mathbb{Z}$. Then $b^{2}=a^{2n} \Rightarrow 1=b^{2}a^{-2n}=(ba^{-n})^{2}=d^{2}$.So if we consider $G$ is the disjoint union of $H$ and $dH$, then we see the multiplication table of $G \backsimeq \mathbb{Z}\times \mathbb{Z}/2\mathbb{Z}$ where $H \backsimeq \mathbb{Z}$. Now suppose that $\phi_{b}=$inversion. We know that $b^{2}=a^{k}$ for some $k\in \mathbb{Z}$. Then $b=b^{-1}a^{k}\Rightarrow b^{2}=b^{-1}a^{k}b=\phi_{b}(a^{k})=a^{-k}$. So we have $a^{k}=a^{-k}\Rightarrow 1=(a^{k})^{2}=f^{2}$ where $f=a^{k}$. Now if we consider $G$ as the disjoint union of $H$ and $fH$, then we know the multiplication table of $G$. In fact it  is the infinite dihedral group.
