In order to improve the practicability of Grover’s algorithm, this paper designs a flexible phase selection strategy and an initial state construction method for an unstructured database. The flexibility of the proposed algorithm is manifested in three aspects. First, it is suitable for an unordered database of any size, unlike traditional algorithms that must be an integer power of 2. In the existing approach, one must use padding when this requirement is not met. To this end, we propose a design method for an equal quantum superposition state containing any number of basis states. Second, the rotation phase in the search engine can be fixed to any value in the interval (0,π]\documentclass[12pt]{minimal}
\usepackage{amsmath}
\usepackage{wasysym}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsbsy}
\usepackage{mathrsfs}
\usepackage{upgreek}
\setlength{\oddsidemargin}{-69pt}
\begin{document}$$(0, \pi ]$$\end{document}. We investigate the relationship between the rotation phase in the search engine and the probability of success and the number of search steps, and provide the formulas for calculating the probability of success and the number of search steps under any rotation phase. Third, for the case where the number of marked items is not known in advance, a specific search scheme using the search engine with rotation phase of π/3\documentclass[12pt]{minimal}
\usepackage{amsmath}
\usepackage{wasysym}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsbsy}
\usepackage{mathrsfs}
\usepackage{upgreek}
\setlength{\oddsidemargin}{-69pt}
\begin{document}$$\pi /3$$\end{document} is also given, and theoretical analysis shows that it can find a match in O(N/M)\documentclass[12pt]{minimal}
\usepackage{amsmath}
\usepackage{wasysym}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsbsy}
\usepackage{mathrsfs}
\usepackage{upgreek}
\setlength{\oddsidemargin}{-69pt}
\begin{document}$$O(\sqrt{N/M})$$\end{document} search steps, where N is the total number of basis states and M is the number of marked states.