Database Search Sample

This sample walks through Grover's search algorithm. Oracles implementing the database are explicitly constructed together with all steps of the algorithm.

This sample features three examples:

  1. A search made without any Grover iterations, equivalent to a random classical search.
  2. A quantum search using manually implemented Grover iterations to amplify the marked element.
  3. A quantum search using operations from the Q# standard library to amplify multiple marked elements.


Running the Sample

This sample can be run in a number of different ways, depending on your preferred environment.

Visual Studio Code or the Command Line

At a terminal, run the following commands for each of the three examples.

Example 1

dotnet run simulate Microsoft.Quantum.Samples.DatabaseSearch.RunRandomSearch

Example 2

dotnet run simulate Microsoft.Quantum.Samples.DatabaseSearch.RunQuantumSearch

Example 3

dotnet run simulate Microsoft.Quantum.Samples.DatabaseSearch.RunMultipleQuantumSearch

Running the Sample in Jupyter Notebook

This sample can also be viewed using Jupyter Notebook. To do so, ensure that you have the IQ# kernel installed using the instructions in the getting started guide. Then, start a new Jupyter Notebook session from this directory:

cd Samples/src/DatabaseSearch
jupyter notebook