page_type | languages | products | description | jupyter | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
sample |
|
|
This sample shows how to use Q# to search for a marked item with Grover's algorithm. |
|
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:
- A search made without any Grover iterations, equivalent to a random classical search.
- A quantum search using manually implemented Grover iterations to amplify the marked element.
- A quantum search using operations from the Q# standard library to amplify multiple marked elements.
- The Microsoft Quantum Development Kit.
This sample can be run in a number of different ways, depending on your preferred environment.
At a terminal, run the following commands for each of the three examples.
dotnet run simulate Microsoft.Quantum.Samples.DatabaseSearch.RunRandomSearch
dotnet run simulate Microsoft.Quantum.Samples.DatabaseSearch.RunQuantumSearch
dotnet run simulate Microsoft.Quantum.Samples.DatabaseSearch.RunMultipleQuantumSearch
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
- DatabaseSearch.qs: Q# code implementing quantum operations for this sample.
- Program.qs: Q# code to interact with and print out results of the Q# operations for this sample.
- DatabaseSearchSample.csproj: Main C# project for the sample.
- Database Search.ipynb: The sample as a Jupyter Notebook.