page_type | languages | products | description | ||
---|---|---|---|---|---|
sample |
|
|
This sample implements Grover's search algorithm, an example of a quantum development technique known as amplitude amplification. |
This sample implements Grover's search algorithm, an example of a quantum development technique known as amplitude amplification. Oracles implementing the database are explicitly constructed together with all steps of the algorithm. See the DatabaseSearch sample for and extended version and the Grover Search Kata to learn more about Grover's algorithm and how to implement it in Q#.
This sample uses the example of an operation that marks inputs of the form "010101…", then uses Grover's algorithm to find these inputs given only the ability to call that operation. In this case, the sample uses a hard-coded operation, but operations and functions in the Microsoft.Quantum.AmplitudeAmplification namespace can be used to efficiently and easily construct different inputs to Grover's algorithm, and to quickly build up useful variations of amplitude amplification for different applications. For examples of how to solve more general problems using amplitude amplification, check out the more in-depth database search sample.
- 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 command:
dotnet run
Open the folder containing this sample in Visual Studio ("Open a local folder"
from the Getting Started screen or "File → Open → Folder..." from the menu bar)
and set SimpleGroverSample.csproj
as the startup project.
Press Start in Visual Studio to run the sample.
- SimpleGrover.qs: Q# code implementing quantum operations for this sample.
- Reflections.qs: Q# code implementing quantum operations for this sample.
- SimpleGroverSample.csproj: Main Q# project for the sample.