Searching with Quantum Computers
By Lov K. Grover, April 01, 2001
Source Code Accompanies This Article. Download It Now.
Quantum computers can be in multiple states and carry out multiple computations at the same time and the quantum search algorithm Lov presents here takes advantage of that characteristic.
Apr01: Searching with Quantum Computers
int random(); /* random(N) returns random number between 0 and (N-1) */
int f(); /* f(r) is an arbitrary binary function that returns 1 only
for a single value of r, for all other values of r it returns 0 */
main()
{
int i, r, answer = -1;
r = random(N);
for(i = 0; i < N; i++)
{
if (f(r) == 1) answer = r;
r = random(N);
}
print(answer);
}
Figure 2: Classical probabilistic program.