Homework 3

Due on October 9, 2019 at midnight.

NOTE: The due date is one day after the midterm exam. Obviously, it would be a good idea to do this homework before the exam, because the content will be covered on the exam. But we also want to give you the flexibility to use your time to your best advantage.

Important: Write your name and Unity ID in every submission file. Name the submission files correctly as asked for.

  1. (25 points) Toffoli gate implementation

    The picture below shows one implementation of a Toffoli gate using 1-qubit gates and CNOT. (Source: Wikipedia)

    Toffoli gate implementation

    Implement this Toffoli circuit in Qiskit, as follows:

    You can implement using either Python (.py) or a Jupyter notebook (.ipynb). Submit your solution either as toffoli.py or as toffoli.ipynb.

  2. (20 points) 1-bit full adder

    The files half_adder.py and half_adder.ipynb show an implementation of the gate-model half-adder circuit discussed in class. Download your preferred version of the file and use it as a starting point to implement a full adder circuit. (We're providing this starter file so that you'll follow the directions below!)

    Submit your solution as full_adder.py or full_adder.ipynb.

  3. (30 points) n-bit adder

    Using the previous exercise as a starting point, implement a generalized n-bit adder in Qiskit.

    Submit your solution as adder.py or adder.ipynb.

  4. (25 points) Selective phase change

    Use Qiskit to create a circuit that performs a selective phase shift on a 3-qubit value. Perform a phase shift of π (180 degrees) for states where the AND of all three qubits equals 1.