I wonder if we can utilize Grover's algorithm to solve the following search problem.
Leetcode 33. Search in Rotated Sorted Array
Example 1:
Input: nums = [4,5,6,7,0,1,2], target = 0
Output: true
Example 2:
Input: nums = [4,5,6,7,0,1,2], target = 3
Output: false
Let's ignore the fact that "the array nums
sorted in ascending order" initially and suppose this array is an unstructured list of integers, which satisfied with the problem setting about Grover's algorithm.
So, can I use this Quantum algorithm to solve this problem with $O(\sqrt{N})$ complexity?
How to make an initial uniform superposition with $N$ states, which $N$ is not 2, 4, 8, 16 etc.? For example, I can use 2 qubits and 2 $H$ gates to construct a superposition about $|00\rangle$, $|01\rangle$, $|10\rangle$ and $|11\rangle$, with uniform probabilities $\frac{1}{4}$. But what about a list containing only 3 integers, [0, 2, 3]
, corresponding $\frac{1}{\sqrt{3}}(|00\rangle + |10\rangle + |11\rangle)$. How to use quantum circuit to express this superposition?