Search

Quantum Algorithms - A short introduction

Context

This section is part of Simple Applications: Qubits at Work – from Codebreaking to Climate Modelling, which explores everyday uses of quantum computing.

Table of Contents
Deutsch algorithm 
Deutsch-Jozsa-algorithm 
Shor algorithm 
Grover algorithm with student tasks  

Computers solve problems using algorithms – you can think of an algorithm as being a set of instructions. Classical algorithms run on classical computers, while quantum algorithms run on quantum computers. The key difference between them lies in how they process information.

Classical computers use bits, which can be either 0 or 1. They process data sequentially, solving one step at a time. Even supercomputers, which run algorithms across multiple processors in parallel, still execute those algorithms in a step-by-step manner. While classical algorithms are highly efficient for many tasks, they become inefficient for complex problems such as breaking encryption or simulating large molecules – because the runtime of the programs becomes just too large.

Quantum computers use qubits, which can be in a superposition of two states. This allows quantum algorithms to process computation steps simultaneously, making them much faster to solve certain type of problems. Another key property of quantum physics, entanglement, enables qubits to be linked to each other, again improving the computation efficiency.

Deutsch algorithm

What it does  
Imagine a function f that takes a single bit (0 or 1) as input and produces a single bit as output. There are four possible functions for describing this: two constant functions ( f ( 0 ) = f ( 1 ) = 0 or f ( 0 ) = f ( 1 ) = 0 ) and two so-called balanced functions ( f ( 0 ) f ( 1 ) ) . The Deutsch algorithm can determine whether the function f is constant or balanced.

Quantum vs. classical 
Classically, to determine if the function is constant or balanced, you would need to evaluate the function for both inputs, f ( 0 ) and f ( 1 ) . This requires two function evaluations. The Deutsch algorithm, however, achieves the same result with just one quantum query to the function.

While the speedup in the Deutsch algorithm might seem minor (going from two evaluations to one), it highlights a fundamental difference between classical and quantum computation. It demonstrates that quantum computers can sometimes gain information about a function with fewer queries than classical computers. This principle is at the heart of many more complex quantum algorithms, like Shor's algorithm.

The Deutsch algorithm is a very specific example. It is not directly applicable to a wide range of problems. Its primary purpose is pedagogical, illustrating the basic principles of quantum computing in a clear and concise way. It paves the way for more sophisticated algorithms like the Deutsch-Jozsa algorithm, which generalises the Deutsch algorithm to functions with multiple inputs and shows an even more drastic quantum speedup.

Deutsch-Jozsa-algorithm

What it does 
Imagine a function f that takes n bits as input and produces a single bit as output. The Deutsch-Jozsa algorithm determines whether the function is constant (meaning it outputs the same bit for all possible inputs) or balanced (meaning it outputs 0 for exactly half of the inputs and 1 for the other half). 

Quantum vs. classical 
Classically, to determine if the function is constant or balanced, you would need to evaluate the function for all possible inputs. Since there are   2 n possible inputs, this requires 2 n function evaluations. If the function is balanced, you might be lucky and determine it after fewer tries, but in the worst case, you have to check half of the inputs. The Deutsch-Jozsa algorithm, however, can determine the nature of the function with just one quantum query to the function, regardless of the number of input bits n .

The Deutsch-Jozsa algorithm showcases an exponential speedup over classical algorithms. While the problem it solves might seem contrived, it demonstrates that quantum computers can solve certain problems with exponentially fewer steps than classical computers.

 

Like the Deutsch algorithm, the Deutsch-Jozsa algorithm solves a very specific problem. Its primary purpose is to illustrate the power of quantum computing and to serve as a stepping stone to understanding more complex quantum algorithms. It highlights the potential for exponential speedup, which is a key motivation for research in quantum computing.

Shor's algorithm 

What it does 
Shor's algorithm is a quantum algorithm that efficiently finds the prime factors of large integers. This is a problem recognised for its computational difficulty on classical computers, and is thus the reason why prime factorisation is widely used for encryption methods like the RSA encryption (RSA stands for the inventors of the method: mathematicians Rivest, Shamir and Adleman). A quantum computer that uses Shor's algorithm to efficiently factorise large numbers poses a significant threat to current cryptographic systems.

Quantum vs. classical 
The key difference lies in the period-finding step, i. e. finding one or several periodical patterns in the factors of the factorisation. Classical algorithms for finding the period require exponential runtime, meaning the time it takes to factorise a given number increases exponentially with the size of the number. For very large numbers, the runtime is just absurdly large to have it run on a classical computer. Shor's algorithm, however, can find the period in a polynomial runtime. This is a dramatic speedup.

The existence of Shor's algorithm has huge implications for cryptography. RSA encryption and other public-key cryptosystems rely on the difficulty of factorising large numbers. If a sufficiently large quantum computer was built, it could break these widely used encryption methods. This has spurred research in quantum-resistant cryptography, which aims to develop encryption algorithms that are secure even against attacks from quantum computers. Shor's algorithm is not just a theoretical curiosity, it's a practical threat that has significant real-world consequences.

Grover algorithm

Grover's algorithm is a quantum algorithm for searching an unsorted database. It offers a significant speedup for this kind of problems.

Quantum vs. classical 
In classical computing, searching for an item in an unsorted database of N entries requires, on average, checking N/2 entries. In the worst case, you might have to check all N entries (N – 1 to be exact). Grover's algorithm, however, only requires approximately √N steps to find the target entry. This is a speedup, which becomes more relevant as the size of the database grows.

Grover's algorithm has profound implications for various fields:

  • Cryptography: It can be used to break certain encryption types, highlighting the need for quantum-resistant cryptographic methods.
  • Optimisation: It can speed up the solution of optimisation problems, such as finding the shortest route between two locations.
  • Data mining: It can be used to find patterns in large datasets more efficiently.

While still theoretical in many aspects due to the limitations of current quantum computers, Grover's algorithm showcases the potential of quantum computing to revolutionise how we solve certain problems.

Worksheet: Understanding Grover's algorithm

Objective: To get a basic understanding of how Grover’s algorithm works and how it can speed up a search in an unsorted list of items. You need to be a group of five students to carry out this exercise.

Download worksheet with solution as docx or as pdf.
Download worksheet for students as docx or as pdf.

Close search