Finding a given group in groups twice as large. Given a group $H$ with order $n$, can we determine how many groups $G$ of order $2n$ contain $H$ as a subgroup, and perhaps find these groups? For example, $\mathbb{Z}_4$ is contained in $\mathbb{Z}_8$, $\mathbb{Z}_4 \times \mathbb{Z}_2$, $D_4$, and $Q_8$.
I'm curious if we can find a constant upper bound (or upper bound related to $n$) on the number of groups $G$ that satisfy my constraints for any $H$. I'm not very familiar with group theory, so methods to approach this might be over my head. I'm particularly interested in the case where we only consider cyclic $H$. Feel free to generalize! Thanks.
 A: Subgroups of index $2$ are normal, so equivalently you want to classify short exact sequences
$$1 \to H \to G \to \mathbb{Z}_2 \to 1.$$
In other words, you want to classify extensions of $\mathbb{Z}_2$ by $H$. If $H$ has odd order then such a short exact sequence must split (this generalizes to the Schur-Zassenhaus theorem, but in this case we can just appeal to Cauchy's theorem), so $G$ must be a semidirect product
$$G \cong H \rtimes \mathbb{Z}_2$$
and now it suffices to classify actions of $\mathbb{Z}_2$ on $H$. If $H = \mathbb{Z}_n$ where $n$ is odd then write $n = \prod p_i^{e_i}$ where the $p_i$ are odd primes and $k$ primes appear. Then
$$H \cong \prod_i \mathbb{Z}_{p_i^{e_i}}$$
so there are $2^k$ actions of $\mathbb{Z}_2$ on $H$, given by acting by $\pm 1$ on each factor. The corresponding extensions take the form
$$G \cong \mathbb{Z}_a \times D_b$$
where $D_b$ is the dihedral group $\mathbb{Z}_b \rtimes \mathbb{Z}_2$ and $ab = n$.
If $H$ has even order then the answer is more complicated and involves group cohomology. To give some indication of how complicated the answer must be, every finite $2$-group is an iterated extension of copies of $\mathbb{Z}_2$. There are more than 49 billion groups of order $1024 = 2^{10}$, and they make up almost all groups of order less than $2000$. By contrast, there are 10 million groups of order $512$. This means at least one group of order $512$ is a subgroup of at least $5000$ groups of order $1024$. In general, it's known that the number of groups of order $2^n$ is asymptotically
$$2^{\frac{2}{27} n^3 + O(n^{8/3})}$$
so at least one group of order $2^n$ is a subgroup of somewhere around $2^{\frac{2}{9} n^2}$ groups of order $2^{n+1}$; note that this is faster than polynomial growth in the order. 
If $H = \mathbb{Z}_n$ where $n$ may be even then this is how the classification begins. First, you still need to classify all actions of $\mathbb{Z}_2$ on $\mathbb{Z}_n$. I'll leave this to you as a nice exercise to figure out how to handle the powers of $2$ dividing $n$. Second, fixing such an action, you need to compute the cohomology group
$$H^2(\mathbb{Z}_2, \mathbb{Z}_n)$$
(which depends on the action; unfortunately this is suppressed by the notation). There is one extension for every pair of an action and a class in this cohomology group. If the class vanishes, then the extension is a semidirect product, but in general it won't. 
