# Your Guide to Quantum Algorithms

## An in-depth introduction to the basics of quantum computing, quantum vs classical, and some of the most famous quantum algorithms.

# What is Quantum Computing?

Quantum Computing is a form of computing that takes advantage of **quantum mechanics** to process information exponentially faster than classical computers.

Classical computers use classical bits which can consist of either a 0 or a 1 to encode information. Quantum computers, on the other hand, use quantum bits, or qubits, like photons, atoms, ions, etc. to encode information into 2 distinguishable **quantum states**.

Now you may be thinking, what’s the benefit of using qubits over classical bits? The answer lies in the ability of qubits to behave quantumly, specifically the quantum phenomena of **superposition **and **entanglement**.

## Superposition

When a quantum system is in superposition, it can be a 0 or a 1 or a combination of both, at the same time. This allows a quantum computer to process information at a significantly higher rate than classical computers.

For example, 4 regular bits can only represent 1 of the total 16 combinations at one time. 4 qubits in superposition, however, can be all 16 combinations at once!

## Entanglement

Entanglement is when a pair or group of quantum systems are strongly correlated, giving them the ability to be perfectly in unison, no matter how far apart they are. This means that quantum computers only need to measure 1 qubit and to figure out the value of the other qubit in the pair instantaneously because they are a part of the same entangled system.

# Quantum Algorithms

An algorithm is essentially a series of steps to solve a problem. However, these steps are *limited by the hardware *on which the algorithm is being run on.

For example, let's say we have written down the steps needed to find the derivative of a polynomial function. If we gave these directions to a mathematician they would easily be able to arrive at the correct answer, since they know calculus. If we gave these directions to a student that is currently learning calculus, they would also be able to arrive at the correct answer, but it would probably take a lot more time since they just barely have the experience/knowledge needed. But, if we gave these instructions to a kindergartner, they would be very lost and wouldn’t arrive at an answer. There would probably just be scribbles on the page.

In this example, the steps to calculate a derivative represents an algorithm, and the various people using them represent varying degrees of computing software. Just like how as the person became less and less knowledgeable on physics the efficiency of the steps to be carried decrease in the above analogy, so do computer algorithms.

Certain algorithms take much longer on classical computers that obey the laws of macro physics because their hardware may not be able to carry out some of the steps efficiently.

These algorithms are called **quantum algorithms**, and they can only be run on quantum computers because quantum computers are fundamentally built differently than classical computers.

**Examples**

## 1. Simon’s Algorithm

Simon’s problem was one of the first computational problems to prove that a quantum algorithm could solve a problem exponentially faster than a classical algorithm.

This algorithm, although not providing much practical value on its own, inspired the Quantum Fourier Transforms in Shor’s algorithm, one of the most famous quantum algorithms of all time!

**Qiskit Implementation:**

**Cirq Implementation:**

## 2. Shor’s Algorithm

Shor’s algorithm is by far one of the most famous quantum algorithms of all time, as it can factor integers in polynomial time. It was invented in 1994 by Peter Shor to solve the problem of finding the prime factors of a given number, *N*.

Shor’s algorithm even has the potential to break modern public-key cryptography, like the widespread RSA cryptosystem, on an **ideal **quantum computer. RSA relies on the impossible nature of factoring the product of two prime numbers for a large enough number. However, this scenario is unlikely to happen in the near future because we still have a lot more progress to make in lowering quantum noise and quantum decoherence in current quantum computers.

Still, Shor’s algorithm is an extremely efficient project in giving you a hands-on experience with using a quantum Fourier transform especially for those that are interesting in the intersection of QC and Cryptography!

**Qiskit Implementation:**

**Cirq Implementation:**

## 3. Deutsch-Jozsa Algorithm

The Deutsch-Jozsa Algorithm was proposed by David Deutsch and Richard Jozsa in 1992 to showcase how quantum algorithms can be exponentially faster than any possible deterministic classical algorithm.

The algorithm itself doesn’t provide much practical use besides being specifically designed to be easy for a quantum algorithm and hard for any deterministic classical algorithm.

The Deutsch-Jozsa problem consists of an oracle that implements a hidden boolean function, which takes as input a string of bits, and returns either 0 or 1. The Deutsch-Jozsa quantum algorithm produces an answer that is always correct with a single evaluation of the function.

**Qiskit Implementation:**

**Cirq Implementation:**

## 4. Grover’s Algorithm

Lov Grover created this algorithm to solve the problem of an unstructured search. It can find the unique input to a black box function that produces a particular output value, using just O(sqrt N) evaluation of the function, N being the function’s domain.

In other words, let's say we had a shuffled deck of cards and were tasked with finding 1 specific card. The *classical* algorithm would solve this by going through all the cards in the deck one by one, or *N* evaluations. On the other hand, Grover’s algorithm would only require O(sqrt N) evaluation to do the same job.

Unlike the previous quantum algorithms mentioned, Grover’s algorithm only provides a quadratic speedup in evaluation time for unstructured searches, compared to their exponential speedup. Still, the amplitude amplification trick employed in Grover’s algorithm is extremely useful when trying to obtain quadratic run time improvements for a variety of other algorithms.

**Qiskit Implementation:**

**Cirq Implementation:**

## 5. Bernstein-Vazirani Algorithm

The Bernstein-Vazirani Algorithm was invented by Ethan Bernstein and Umesh Vazirani in 1992. It is a restricted version of the Deutsch–Jozsa algorithm.

The algorithm was created to solve a is

So, let’s just say that we are given a **box**. Hidden in the box is a secret number. This “secret number” is represented by six bits made up of 0’s and 1’s. We need to figure out what the “secret number” is.

Classically, a computer would find it most efficient to calculate the “secret number” by evaluating the function *n *times, where x = 2^i and i is the summation of 0, 1, … n-1.

Now imagine if you could find out what the secret number is in **one try, **no matter its size. That’s exactly what running the Bernstein-Vazirani algorithm on a **quantum computer** allows you to do.

**Qiskit Implementation:**

**Cirq Implementation:**

*Hi! I’m Nidhi Jadhav. I am 16 years old and incredibly passionate about AI and Quantum Computing. Thank you so much for reading my article! If you want to learn more about new emerging technologies, follow me, connect with me on **Linkedin**, or email me at nidhivjadhav@gmail.com for any inquiries. Thanks again!*