Reconstructing a manifold from critical points

I am teaching theoretical calculus this semester, and on the last discussion section we were discussing critical points of functions. I explained the idea of Morse theory, and a student of mine asked me a question that I couldn't answer. I don't know a lot about the Morse theory, so the question might actually be easy. I would really appreciate if you can help me, or at least give me a reference.

Suppose you are given an ordered set of signatures (i.e. number of $+$ and $-$ of the hessian) $\{(a_1,b_1),\dots,(a_r,b_r)\}$, that is supposed to be a set of critical points of some Morse function on a would be a $k$-manifold. The question is the following:

When there exists a manifold with a Morse function having a given set of signatures of critical points?

It is easy to see that the set of signatures must have signatures of the form $(k,0)$ and $(0,k)$, since any function on a compact manifold must have minimum and maximum.

Also, we can't start with, say, $(k-1,1)$, since you must start with the point of minimum, which must be of signature $(k,0)$.

Also, it is not true that we can always construct a manifold with given ordered set of signatures. For example, take the set $\{ (2,0) , (1,1), (0,2) \}$. Following the algorithm, first we attach a 0-cell, then we attach a 1-cell. Topologically it will be equivalent to a letter U made out of a tube (cylinder). But then you need two "caps" to make it into a closed compact thing, but we have only one critical point left.

I have no idea what are the conditions when we can actually construct a required manifold.

I've heard (but I am not sure if it is true) that if we have passed a sertain number of critical points in out reconstructing algorithm (maybe more than $r/2+1$), then there is unique way to finish the procedure to get a closed compact manifold. If this is correct, is it still true that we can always get a manifold having any set of the first $r/2+1$ signatures?

Thank you very much!

-
A couple of thoughts, not well-formed (or well-remembered) enough for an answer. The place you want to look is surgery theory. Handle slides should let you rearrange your critical points so the cell dimensions are monotone increasing in index. Once you get to the halfway dimension, I think Poincare duality should finish the job ("turning upside down"). There are $K$- and $L$-theoretic algebraic obstructions to gluings in the lower dimensions. Check out Ranicki's book, see also survey papers like math.uchicago.edu/~shmuel/tom-readings/… –  Neal Nov 23 '13 at 2:54

Here's a lemma that partially answers the question for odd-dimensional manifolds. It's certainly not the case that $n_0,\ldots, n_k$ uniquely determines $n_{k+1},\ldots, n_{2k+1}$ though, since you can always make an equivalent handle decomposition by introducing a canceling pair of critical points. The even case is trickier since there exists a middle dimension.
Lemma: Let $n_0,\ldots, n_k$ be a sequence of nonnegative integers with $n_0>1$. Then there is a $2k+1$-manifold with $n_i$ critical points of index $i$ for $i\leq k$.
Proof: We build a manifold with boundary by attaching handles. We start with $n_0$ 0-handles. Then we attach $n_1$ $1$-handles in some way. In general, we want to be attaching the $i$-handles along regions $\partial(D^{i})\times D^{n-i}$, and in order to proceed, we need to know such regions exist in the boundary. Since $i<2k+1$, it is easy to find an embedded $S^{i-1}$ inside the $2k$-dimensional boundary. Indeed you can find it inside some open set homeomorphic to a $(2k)$-ball. Then a regular neighborhood is isomorphic to $S^{i-1}\times D^{n-i}$. Okay, so in this way we've built up a manifold with boundary, $M$, that has all the correct critical points up to index $k$. Now take the double of this manifold $D(M)=M\cup_{\partial M}M$. Critical points of index $i$ turn into critical points of index $2k+1-i$ when you turn $M$ upside down, so $D(M)$ has critical points of index $n_0,\ldots, n_k,n_k,n_{k-1},\ldots n_0$. $\Box$