You are given a list of numbers and a target number, and you are asked to find the index in the list at which the target number appears. If the list is sorted, you can use search algorithms such as binary search. But if the list is not sorted, there isn’t really much you can do; you simply have to traverse the whole list till you find the element. In terms of algorithmic complexity, this takes O(N) time. With a quantum computer, however, you can solve this problem in just O(√N) time. This article explains how this is achieved by the Grover’s search algorithm.
_If you’re new to quantum computing, you should first read this short primer: _Quantum parallelism — where quantum computers get their mojo from.
Needle in a haystack (Image from Pixabay)
Let’s start by framing the problem. We are given:
X = {x_1, …, x_i, … ,x_N}
such that each x_i
is an m-bit string made of 0s and 1s.x*
that is also an m-bit string made of 0s and 1sx*
and 0 otherwise. This function can be written as:Grover’s search works in three steps as described below.
Step 1: Setup the state
A quantum state is set up in an equal superposition of the basis states. As an example, consider N=8. We set up the state using 3 qubits as:
#search #machine-learning #algorithms #quantum-computing #algorithms