State preparation is a process encoding the classical data into the quantum systems. Based on quantum phase estimation, we propose the specific quantum circuits for a deterministic state preparation algorithm and a probabilistic state preparation algorithm. To discuss the gate complexity in these algorithms, we decompose the diagonal unitary operators included in the phase estimation algorithms into the basic gates. Thus, we associate the state preparation problem with the decomposition problem of the diagonal unitary operators. We analyse the fidelities in the two algorithms and discuss the success probability in the probabilistic algorithm. In this case, we explain that the efficient decomposition of the corresponding diagonal unitary operators is the sufficient condition for state preparation problems.