3.)
We know a connected acyclic graph is called a Tree.  So the given alkane or saturated hydrocarbon can be intuitively deemed as a tree.
Following are some facts that we would need to devise an algorithm for the given problem:-
1.    Any tree with \(v\) vertices has \(v-1\) edges.
2.    Sum of degrees of all the vertices is equal to twice the number of edges in the Tree.
            \(\equiv\deg\left(v_1\right)+\deg\left(v_2\right)+....+\deg\left(v_k\right)\ =\ 2\left(k-1\right)\)
So considering each of carbon and hydrogen atoms as vertices and the bonds between them as the edges we can consider the molecule to be a tree.
We are given \(k\) carbon atoms and \(l\ \) hydrogen atoms. So we have \(k+l\) vertices and thus with \(k+l-1\) edges.
And we know the degree of Carbon atom at maximum can be 4 and for Hydrogen atom it can be 1.
Since there are k vertices with degree 4 and l vertices with degree 1, we can write
                                                    \(4k+l=2\left(k+l-1\right)\)
                                                \(\Rightarrow l=2k+2\)
                                                \(\Rightarrow k=\frac{\left(l-2\right)}{2}\)
ALGORITHM
\(if\ l<4\ or\ l\ is\ odd\ then\)
        \(return\ null\)
\(else\)
         \(return\ \frac{\left(l-2\right)}{2}\)