group theory with direct product Find all groups $G$ for which there is an exact sequence
$$\tag1 1\to \mathbb Z_3\to G\to \mathbb Z\to 1$$
And 
$$\tag2 1\to \mathbb Z\to G\to \mathbb Z_2\to 1$$
where $\mathbb Z_3$ means cyclic group of order $3$ and $\mathbb Z_2$ means cyclic group of order $2$.
How to find these group $G$? What is the method? Especially in sequence (2).
 A: Each group in (1) is a semidirect product $\mathbb{Z}_3 \rtimes \mathbb{Z}$ because the sequence splits. So the method of computation is to enumerate all homomorphisms $\mathbb{Z} \mapsto Aut(\mathbb{Z}_3) \approx \mathbb{Z}_2$, use each homomorphism to write the appropriate semidirect product decomposition, and identify the group.
For (2), you are asking for a list of all groups containing an index~2 subgroup that is infinite cyclic. One method, as in the answer of Hagen von Eitzen, is to try to enumerate the possibilities for the group operation. Alternatively, one could try to enumerate the possiblities for generators and relators.
But there is another method for (2), which depends upon Stallings theory of ends. The theory is deep, but the outcome is a method which is easy to apply. Not only that, but you get a side benefit of listing all groups which contain an infinite cyclic subgroup of finite index.
First, you apply the theorem that any group which contains a finite index infinite cyclic subgroup (as in (2)) is a group with two ends. Second, you apply the theorem that every group with two ends can be written as a graph of groups such that each edge group is finite, and such that at each vertex group the sum of the indices of the incident edge groups equals~2. Third, you do a case analysis, enumerating all graphs of groups with these properties, writing down their fundamental groups by explicit formulas. To solve (2) you check each possibility to see whether it has a homomorphism to $\mathbb{Z}_2$ with $\mathbb{Z}$ kernel.
One possibility is that the graph is a circle, and all edge and vertex groups are the same finite group $K$. One can simplify this graph of groups to have exactly one edge and one vertex group. One then obtains a short exact sequence $1 \to K \to G \to \mathbb{Z} \to 1$, and as in (1) this sequence splits and so you get a semidirect product formula $G \approx \mathbb{K} \rtimes \mathbb{Z}$. The only way that this group could have an index 2 infinite cyclic subgroup is when $K$ is the trivial group and so $G=\mathbb{Z}$, or when $K \approx \mathbb{Z}_2$ in which case $G=\mathbb{Z}_2 \oplus \mathbb{Z}$.
The other possibility is that the graph is a segment, all edge groups and interior vertex groups are the same finite group $K$, and each vertex group at the endpoint of the segment is a group containing $K$ with finite index. One can simplify this graph of groups to have exacty one edge and two vertex groups. In this case, by computing the fundamental group one gets a short exact sequence of the form $1 \to K \to G \to D_\infty \to 1$ where $D_\infty$ is the infinite dihedral group. The only way that such a group $G$ could contain an infinite cyclic group of index 2 is if $K$ is trivial, and so $G \approx D_\infty$.
A: As a set, we can always take $G=A\times B$ if $1\to A\to G\to B\to 1$, so that the arrows are just $a\mapsto (a,e)$ and $(a,b)\mapsto b$. But what group operation?
We must obey $(a,e)*(a',e)=(aa',e)$ and $(a,b)*(a',b')=(?,bb')$.
Of course, one solution is just to let $G=A\oplus B$.
Another oprtion is, if we have a group action of $B$ on $A$, we can take the corresponding semidirect product.
Here the is only one (nontrivial) action of $\mathbb Z$ on $\mathbb Z_3$, and of $\mathbb Z_2$ on $\mathbb Z$.
To look for additional solutions (i.e. where the sequence does not split), it may be helpful to play with the conditions listed in the first paragraph.  (Of course by the very definition of $\mathbb Z/2\mathbb Z$ we find another(?) solution of $(2)$).
