The present paper investigates properties of quasi stable ideals and of Borel-fixed ideals in a polynomial ring k[x0, . . . , xn], in order to design two algorithms: the first one takes as input n and an admissible Hilbert polynomial P(z), and outputs the complete list of saturated quasi stable ideals in the chosen polynomial ring with the given Hilbert polynomial. The second algorithm has an extra input, the characteristic of the field k, and outputs the complete list of saturated Borel-fixed ideals in k[x0, . . . , xn] with Hilbert polynomial P(z). The key tool for the proof of both algorithms is the combinatorial structure of a quasi stable ideal, in particular we use a special set of generators for the considered ideals, the Pommaret basis.