A quick interlude on classical search
Before we hit the Grover algorithm, let's just take a quick peek at a standard, classical linear search algorithm. For a classical algorithm that searches an unordered database, the average number of times you have to look for a given entry is of the order of where N is the number of items in the database. For example, if your unordered database has four items, you will generally have to look an average of two times to find your item.
Getting ready
The sample code for this recipe can be found here: https://github.com/PacktPublishing/Quantum-Computing-in-Practice-with-Qiskit-and-IBM-Quantum-Experience/blob/master/Chapter09/ch9_r2_classic_search.py.
How to do it…
Let's search for a specific two-bit entry in a small database with four items:
- First, we need to enter the two-bit string that we are searching for, and then the number of searches to try to get some statistics:
Searching in a scrambled database with...