Generalization of Quantum Search Algorithm