-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Learn Quantum Computing with Python and IBM Quantum - Second Edition
By :
Which algorithm would you use to determine whether an n-bit string is balanced?
The Deutsch-Jozsa algorithm can be used to determine whether a function is constant or balanced.
Implement the Bernstein-Vazirani algorithm to find the state 170.
To create the circuit, you need the binary representation of 170. Then, after applying a Hadamard gate to all the qubits, except the ancilla qubit, to which you will first apply a NOT gate followed by a Hadamard gate, apply a CX gate to each qubit that is represented by the binary value for 170, which is represented by the value 10101010. So, you would apply a CX gate to each of the odd qubits, where the control of each CX gate should be set to qubit 1, 3, 5, and 7 and the target of each CX gate is the ancilla qubit. Then, apply a Hadamard gate followed by a measurement operator to all qubits except the ancilla qubit.