Undergraduate Journal of Mathematical Modeling: One + Two

Volume 4 | 2012 Spring Article 2

2012

The Subset Sum Problem: Reducing of NP- Completeness with Quantum Search

Bo Moon University of South Florida

Advisors: Manoug Manougian, Mathematics and Statistics Jing Wang, Computer Science & Engineering

Problem Suggested By: Jing Wang

Follow this and additional works at: https://scholarcommons.usf.edu/ujmm

Part of the Mathematics Commons

UJMM is an open access journal, free to authors and readers, and relies on your support: Donate Now

Recommended Citation Moon, Bo (2012) "The Subset Sum Problem: Reducing Time Complexity of NP-Completeness with Quantum Search," Undergraduate Journal of Mathematical Modeling: One + Two: Vol. 4: Iss. 2, Article 2. DOI: http://dx.doi.org/10.5038/2326-3652.4.2.2 Available at: https://scholarcommons.usf.edu/ujmm/vol4/iss2/2 The Subset Sum Problem: Reducing Time Complexity of NP-Completeness with Quantum Search

Abstract The Subset Sum Problem is a member of the NP-complete class, so no known polynomial time algorithm exists for it. Although there are polynomial time approximations and heuristics, these are not always acceptable, yet exact-solution algorithms are unfeasible for large input. Quantum computation offers new insights for not only the Subset Sum Problem but also the entire NP-complete class; most notably, Grover's quantum algorithm for an unstructured database search can be tailored to identify solutions to problems within mathematics and computer science. This paper discusses the physical and conceptual feasibility of quantum computation and demonstrates the utility of quantum search by analyzing the time complexities of the classical algorithm and Grover's algorithm in solving the Subset Sum Problem, evincing the implications this has on the NP-complete class in general.

Keywords NP Completeness, Quantum Search, Subset Sum Problem

Creative Commons License

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 4.0 License.

This article is available in Undergraduate Journal of Mathematical Modeling: One + Two: https://scholarcommons.usf.edu/ujmm/vol4/iss2/2 Moon: The Subset Sum Problem: Reducing Time Complexity of NP-Completene 2 BO MOON

TABLE OF CONTENTS

Problem Statement ...... 3

Motivation ...... 3

Mathematical Description and Solution Approach ...... 4

Discussion ...... 23

Conclusion and Recommendations ...... 25

Nomenclature ...... 26

References ...... 27

Produced by The Berkeley Electronic Press, 2012 Undergraduate Journal of Mathematical Modeling: One + Two, Vol. 4, Iss. 2 [2012], Art. 2

THE SUBSET SUM PROBLEM: REDUCING TIME COMPLEXITY OF NP-COMPLETENESS WITH QUANTUM SEARCH 3

PROBLEM STATEMENT

The Subset Sum Problem is a member of the NP-complete class of computational

problems, having no known polynomial time algorithm. The purpose of this paper is to compare the

time complexities of a quantum search algorithm and a classical dynamic programming algorithm as

solutions to this problem.

MOTIVATION

In computational complexity theory, problems within the NP-complete class have no

known algorithms that run in polynomial time. The study of NP-completeness is significant, as

computer science problems lurk in many guises across a variety of disciplines, from chemical

informatics to networking. As such, identifying a problem as NP-complete will conserve both

time and effort for the computer scientist, who can avoid a fruitless pursuit for an efficient

algorithm by knowing beforehand that there are currently none in existence. Of course, NP-

complete problems can still be solved, but either the input data must be restricted to reasonably

small sizes to accommodate superpolynomial time algorithms or accuracy must be compromised

in implementing faster approximation algorithms, neither of which are amenable conditions.

Although most algorithms for NP-complete problems are just short of a brute-force

search, the immense computational power of a quantum computer may give impetus to more

efficient solutions. A quantum search algorithm provides a

framework for finding a solution in a finite search space defined in terms of the problem, running

faster than a classical algorithm but admittedly still exponential. As such, this paper will

demonstrate the utility of quantum search in solving the NP-comple

algorithm to a specific instance of NP-completeness the Subset Sum Problem. As it shall be

https://scholarcommons.usf.edu/ujmm/vol4/iss2/2 DOI: http://dx.doi.org/10.5038/2326-3652.4.2.2 Moon: The Subset Sum Problem: Reducing Time Complexity of NP-Completene 4 BO MOON

soon revealed, a classical algorithm can do no better than a complete search while a quantum

search runs drastically faster by exploiting the principles of superposition and quantum

parallelism on an unstructured database.

MATHEMATICAL DESCRIPTION AND SOLUTION APPROACH

A. THE SUBSET SUM PROBLEM AND DYNAMIC PROGRAMMING

The Subset Sum Problem is as follows: Given a set of positive integers and a positive

target integer , determine whether there exists a subset of whose elements sum to

(Neapolitan and Naimipour). This problem has been shown to be NP-complete by reduction to

the satisfiability problem, so no known polynomial time algorithm exists (Dasgupta,

Papadimitriou and Vazirani). One possible algorithm is to generate all possible nonempty

subsets of through a depth-first search and to sum the elements in each set in time,

terminating only when is reached. This yields a complete search algorithm with a runtime of

. A slightly faster algorithm in pseudopolynomial time can be achieved with dynamic

programming.

In order to apply dynamic programming, the Subset Sum Problem must exhibit optimal

substructure and overlapping subproblems. Optimal substructure appears when the solution to a

problem relies on the solutions to smaller cases. In the Subset Sum Problem, suppose that one

element of the solution subset is known. The original problem is now reduced to finding a

subset of elements that adds up to , so this subproblem consists of fewer elements

and a smaller sum. Thus, an algorithm for the Subset Sum Problem can utilize optimal

substructure by iterating over all to create the subproblems, iterating over recursively on

Produced by The Berkeley Electronic Press, 2012 Undergraduate Journal of Mathematical Modeling: One + Two, Vol. 4, Iss. 2 [2012], Art. 2

THE SUBSET SUM PROBLEM: REDUCING TIME COMPLEXITY OF NP-COMPLETENESS WITH QUANTUM SEARCH 5

those subproblems until a base case is reached, and then conflating the solutions in order to solve

the original problem, thereby reducing the number of time-consuming operations done.

Overlapping subproblems occur when multiple subproblems consisting of identical parameters

are solved. Consider two subproblems with sets and and corresponding target sums and

such that but . If it is possible to solve either case, then solving the other is

unnecessary, as the succeeding case that gave rise to these subproblems requires only the fact

whether or not it is possible to reach the sum regardless of the set used. As a result, overlapping

subproblems can be avoided by recording solutions to subproblems in a table as they are solved

and referring to it to determine if a particular recursive call is unique or has already been visited,

so fewer cases are solved. Since the Subset Sum Problem possesses both optimal substructure

and overlapping subproblems, a dynamic programming algorithm can be applied.

To exploit optimal substructure, a recursive relationship must be identified such that

solutions to problems of smaller dimensionality are somehow combined. Let the function

return a Boolean value of true if it is possible to add to using the th element in the set and false

otherwise. Given a target sum and an element , the only valid operations are to either use the

element, resulting in a subproblem with target sum and element , or skip the element,

creating another subproblem with target sum and element . Using a logical OR operator on

these two cases in functional form will determine whether it is possible to solve at least one of

them and ultimately the previous recursive call as well. The function returns 1 when ,

indicating that the target sum has been successfully reached, and returns when either is

negative or , which means either the subset sum has surpassed the target or the subset is out

of elements respectively. The subproblems and the base cases can be represented as

https://scholarcommons.usf.edu/ujmm/vol4/iss2/2 DOI: http://dx.doi.org/10.5038/2326-3652.4.2.2 Moon: The Subset Sum Problem: Reducing Time Complexity of NP-Completene 6 BO MOON

so that will solve the original problem statement.

To avoid overlapping subproblems, the algorithm uses a matrix where the element at the

th row and th column conveniently holds the value . In implementing the function, one

would refer to the matrix prior to evaluating each recursive call in order to check whether the

particular subproblem has already been solved. If so, the element is retrieved, otherwise the

matrix entry is filled in as soon as is resolved so that future subproblems can refer to it.

B. TIME COMPLEXITY OF THE DYNAMIC PROGRAMMING ALGORITHM

Since this dynamic programming algorithm solves each subproblem exactly once and the

space of all subproblems can be represented by an matrix, the time complexity of this

algorithm is equivalent to the total number of elements in the matrix. With rows and

columns, there are subproblems. Therefore, the time and space complexity of this dynamic

programming algorithm is . For a more thorough evaluation of time complexity, let be

the number of distinct sums that must be created with the given set so that the following cases

can explain its pseudopolynomial time behavior.

In the worst case scenario, is greater than or equal to the sum of all elements in the set.

As a result, the algorithm must visit every possible sum in order to determine if can be reached

at all. By elementary number theory, there are distinct nonempty subsets, so is

bounded above as such:

Therefore, the original time complexity (where ) can be rewritten as .

Produced by The Berkeley Electronic Press, 2012 Undergraduate Journal of Mathematical Modeling: One + Two, Vol. 4, Iss. 2 [2012], Art. 2

THE SUBSET SUM PROBLEM: REDUCING TIME COMPLEXITY OF NP-COMPLETENESS WITH QUANTUM SEARCH 7

Consider the alternate case when is less than the sum of all elements in the set. The

algorithm does not consider every possible subset sum since some would clearly be greater than

. Consequently, the algorithm visits only the unique sums under the worst conditions

for this particular case, so . For example, consider the set with .

There are possible subset sums, but only the sums will be considered

because any greater sum is unnecessary, so . Therefore, these conditions preserve

the complexity.

This dynamic programming algorithm is considered to be pseudopolynomial because it

behaves as a polynomial time algorithm for large elements in and relatively small , but it is

not actually polynomial time as previously shown. However, it is reasonable to conclude that its

runtime is because this represents the worst-case conditions according to order of

growth analysis, and one cannot ensure that is indeed bounded by the sum of the elements in

the set. Note that the complete search algorithm given earlier also runs in . Although the

time complexities of both algorithms are identical, the dynamic programming one is generally

faster due to its use of optimal substructure and overlapping subproblems. In fact, this is the

fastest known runtime of any classical algorithm for the Subset Sum Problem.

C. OVERVIEW OF QUANTUM COMPUTATION

A quantum computer is one that manipulates the components of its internal state by

exploiting the principles of quantum mechanics (Mermin). Though both classical and quantum

computers share the elementary functionality of Turing machines, quantum computers utilize

special properties of physical systems that are precisely why quantum algorithms are so efficient

(Rosen). Thus, a basic understanding of quantum computational theory is necessary prior to

implementing a quantum search algorithm.

https://scholarcommons.usf.edu/ujmm/vol4/iss2/2 DOI: http://dx.doi.org/10.5038/2326-3652.4.2.2 Moon: The Subset Sum Problem: Reducing Time Complexity of NP-Completene 8 BO MOON

In classical computers, all operations and data storage are dependent upon the bit, the

fundamental computational unit. It can assume only one of two discrete states, or , which can

or false, or as binary

numbers when multiple bits are strung together. Analogously, quantum computers rely on

quantum bits, or qubits, for data manipulation. Qubits can also be associated with the

aforementioned states, conventionally written in Dirac notation as and (Viamontes,

Markov and Hayes).

Whereas classical bits can be stored using high and low voltages in computer chips,

qubits must have a representation grounded in the physical world in order to be properly

manipulated. For example, using a hydrogen atom, the states and corresponds to an

electron in the excited state and in the ground state respectively (Dasgupta, Papadimitriou and

Vazirani). Abstractly, however, the linearity of quantum mechanics allows linear algebra to aptly

model qubits as vectors and bit manipulations as unitary transformations.

One of the major differences between qubits and classical bits is that the former are

subject to the superposition principle, which states that a quantum system can exist in a linear

superposition of all possible states (Dasgupta, Papadimitriou and Vazirani). As such, a quantum

state of a single qubit can be represented as a unit vector given by a linear combination of the

set of all states, known as the computational basis (Mermin):

where , the amplitude of a

such that is normalized, i.e. (Mermin)

.

Produced by The Berkeley Electronic Press, 2012 Undergraduate Journal of Mathematical Modeling: One + Two, Vol. 4, Iss. 2 [2012], Art. 2

THE SUBSET SUM PROBLEM: REDUCING TIME COMPLEXITY OF NP-COMPLETENESS WITH QUANTUM SEARCH 9

The quantum state of a multiple qubit system is the tensor product of the individual qubit states;

for instance, given two qubits, the quantum system is characterized by a superposition of four

computational basis states as (Mermin)

where the first number in each bit string corresponds to the first qubit and the second number

corresponds to the second qubit (this bit string is commonly replaced with its decimal

representation). The state vector is also normalized, following the condition (Mermin)

.

In general, an -qubit system yields a computational basis of states, where the sum of the

squared magnitudes of the amplitudes equals one (Mermin):

The superposition principle is one of the factors contributing to the immense

computational power of a quantum computer. First of all, a quantum system is uniquely defined

by the amplitudes of qubits; for moderately large values of , a classical computer would

require an exponentially large amount of memory, but a quantum computer needs only qubits

to store the amplitudes of the computational basis states (Dasgupta, Papadimitriou and Vazirani).

Secondly, since quantum mechanics conforms to linear algebra quite well, one operation on an

-qubit quantum state is equivalent to simultaneous individual operations on the

computational basis. This phenomenon, known as quantum parallelism, is carried out by the

properties of linear transformations and allows for exponentially large number of operations to

be executed instantaneously, another reason why quantum algorithms outperform their classical

https://scholarcommons.usf.edu/ujmm/vol4/iss2/2 DOI: http://dx.doi.org/10.5038/2326-3652.4.2.2 Moon: The Subset Sum Problem: Reducing Time Complexity of NP-Completene 10 BO MOON

counterparts (Viamontes, Markov and Hayes). Entanglement is another phenomenon that is vital

to many applications of quantum computing, but it will not be discussed here since it holds no

for the Subset Sum Problem are not entangled in a quantum system.

Such an improvement in memory and speed comes with a drawback, however. Although

a qubit is in a linear combination of multiple states, the only way to extract information about

any of them is to make a measurement, the act of observing the state of the qubit (Dasgupta,

Papadimitriou and Vazirani). Unfortunately, merely observing one qubit collapses its mechanical

wave function, forcing its state from the superposition to a single computational

basis state, either or . Similarly, measuring an -qubit system requires the measurement of

each qubit, producing only one state out of a computational basis of

the probability of a particular state arising from a measurement of a system is (Mermin)

.

Note that the normalization condition for the state vector

the magnitude of the vector and the sum of all probabilities is equal to exactly one.

For a given set of qubits, the amplitudes cannot be known, for they are arbitrary complex

numbers; in fact, the system reduces into a single state with an effectively unknown probability,

all amplitudes erased due to measurement. Quantum computers are not deterred, however, as

there remains a way to gather information from qubits.

Since the outcome of a specific state is probabilistic, it is inherent that quantum

algorithms are not deterministic. Classical computers pass bits through electrical circuits and

logic gates in order to manipulate bits, providing the basic functionality algorithms need in order

to operate. Likewise, the general procedure for quantum algorithms is to obtain qubits in a

Produced by The Berkeley Electronic Press, 2012 Undergraduate Journal of Mathematical Modeling: One + Two, Vol. 4, Iss. 2 [2012], Art. 2

THE SUBSET SUM PROBLEM: REDUCING TIME COMPLEXITY OF NP-COMPLETENESS WITH QUANTUM SEARCH 11

known state by measurement and pass them through elementary quantum gates, manipulating the

qubits by enhancing, damping, or inverting amplitudes with the goal of maximizing the

amplitudes and hence the probability of desired states while minimizing those of undesirable

ones (Dasgupta, Papadimitriou and Vazirani). Thus, the goal of the quantum algorithm is to

generate the correct output upon measurement with high probability.

D. QUANTUM GATES

Bit operations in classical computers occur by passing bits through logic gates to be

transformed according to their current states. These gates are physical implementations of the

logical operators AND, OR, XOR, and NOT, and by linking together a series of logic gates, any

computation can theoretically be achieved (Berman, Doolen and Mainieri). Quantum computers

also rely on similar constructions known as quantum gates for bit manipulation. The linearity of

quantum mechanics allows for these quantum gates to be modeled as a linear transformation on

the state vector of the system. The most significant difference between classical logic gates and

quantum ones is the requirement for the matrix representation of any transformation of a

quantum gate to be unitary, that is, the Hermitian conjugate of the matrix is also the inverse

(Nielson and Chuang):

In order for quantum computation to be physically realized, all transformations must

obey the conditions stipulated by the Schrödinger equation (Berman, Doolen and Mainieri).

First, a solution to the Schrödinger equation for a quantum system at an arbitrary moment in time

can be derived from any other known solution (Berman, Doolen and Mainieri). Consequently,

quantum gates must be reversible, as it allows for the qubits to reflect the state of the quantum

computer at any point between computations as long as measurements are not made. Secondly,

https://scholarcommons.usf.edu/ujmm/vol4/iss2/2 DOI: http://dx.doi.org/10.5038/2326-3652.4.2.2 Moon: The Subset Sum Problem: Reducing Time Complexity of NP-Completene 12 BO MOON

for efficient computation, the Hamiltonian of the system should be time-independent (Berman,

Doolen and Mainieri)

environment upon the erasure of a single bit (Nielson and Chuang). Reversible computation

prevents this flow of energy, preserving the Hamiltonian in turn, because erasing bits is

unnecessary when past states can be reconstructed by undoing operations. Thus, all unitary

matrices satisfy these conditions since they are invertible and norm-preserving. Classical logic

gates fail to meet the criteria, mainly because they are not invertible. For example, the XOR

operation takes as input two bits but outputs only one bit; with a loss of information, it is

impossible to derive the state of each input bit given the state of the output bit.

Reversible counterparts of the logic gates exist for quantum computation, so it is possible

to simulate any classical operation with a quantum computer (Berman, Doolen and Mainieri).

Furthermore, it has been shown that any unitary matrix can be decomposed as (Nielson

and Chuang)

where and are real numbers, allowing for an arbitrary construction for a single qubit

quantum gate provided with the correct parameters. This result applies not only for single qubit

gates, however, as it has been shown that any multiple qubit gate can be constructed using one-

and two-qubit gates (Nielson and Chuang)

not be overly concerned with the physical possibility of quantum gates as long as it is known that

any gate can be created. Although arbitrary gates may be constructed, there are two specific

unitary transform and the Hadamard transform.

Produced by The Berkeley Electronic Press, 2012 Undergraduate Journal of Mathematical Modeling: One + Two, Vol. 4, Iss. 2 [2012], Art. 2

THE SUBSET SUM PROBLEM: REDUCING TIME COMPLEXITY OF NP-COMPLETENESS WITH QUANTUM SEARCH 13

1) The Unitary Transform: The standard unitary transform used by most quantum algorithms is

given by (Mermin)

where represents addition modulo 2 and is some auxiliary function, usually the oracle.

accepts a single vector in the form of a tensor product between and , which are

known as the input and output registers respectively (Mermin). The input register is typically the

state of the quantum system, and the output register is some other n-qubit state that varies with

respect to the specific application of . Furthermore, it is clear that the standard unitary

transform is its own inverse. The most significant feature of is that it allows the output

register to record information about via . In this way, it is possible to gain some

information about without collapsing it by measuring instead, leaving

available for further processing (Mermin).

2) The Hadamard Transform: One of the basic quantum gates, the Hadamard transform acting

on a single qubit yields the following (Dasgupta, Papadimitriou and Vazirani):

Like , is its own inverse. More importantly, the properties of tensor products allows for

multiple Hadamard gates to act on multiple qubits. It can be easily verified that (Mermin)

https://scholarcommons.usf.edu/ujmm/vol4/iss2/2 DOI: http://dx.doi.org/10.5038/2326-3652.4.2.2 Moon: The Subset Sum Problem: Reducing Time Complexity of NP-Completene 14 BO MOON

otherwise known as the equal superposition of the computational basis. Qubits in the or

state are easily obtainable by measurement, so is extremely useful in generating a uniform

qubit state when qubits only in the state are available.

E. GROVER S ALGORITHM

an unsorted search space with extremely high probability. Since NP-complete problems are

Sum Problem

with several adjustments and a slight computational overhead. For ease of explanation, it will be

assumed for now that there is only one solution to the Subset Sum Problem, as the presence of

additional solutions affects the algorithm only by enhancing the probability of success.

1) The Oracle: The oracle, also known as the black-box function, is a special function whose

implementation is unknown but can be assumed to execute a specific duty reliably in polynomial

time (Viamontes, Markov and Hayes). Oracles are common in quantum algorithms, as they help

to simplify the problem abstraction and divert attention away from the uninteresting

technicalities of constructing such a basic function. For completeness, however, the structure of

the oracle will be discussed.

state is the one sought after. It is important to clarify that this does not imply that the oracle can

find solutions by itself; rather, the oracle can only test possible solutions in polynomial time.

Furthermore, solution states are trapped within the superposition, so the other operations in

oracle.

For the context of the Subset Sum Problem, define a bijection between subsets of

elements and the states of qubits such that the index of a qubit corresponds with the index of an

Produced by The Berkeley Electronic Press, 2012 Undergraduate Journal of Mathematical Modeling: One + Two, Vol. 4, Iss. 2 [2012], Art. 2

THE SUBSET SUM PROBLEM: REDUCING TIME COMPLEXITY OF NP-COMPLETENESS WITH QUANTUM SEARCH 15

element in the set: if the ith qubit of is , include in the subset, but do not use if the

qubit is . Thus, a one-to-one and onto relation is created, so the oracle can be implemented

through this meaningful bijection.

It is necessary to define another reference for the input size as (by

convention, the logarithm is in base 2). That is, represents the smallest power of greater than

. The number of computational basis states must be a power of , so this refinement of is

required in order to record all the correspondences whenever is not already a power of . Of

course, this means that there may be more computational basis states than the bijection should

allow, but this need not be a hindrance because the oracle can identify and skip any invalid state.

The oracle returns 1 if x matches the desired state and returns otherwise:

where is the qubit state whose bit string representation corresponds to a solution subset

according to the bijection. In order to determine whether a given state is indeed the correct bit

string representation, the oracle will follow the bijection, calculate the corresponding subset sum,

and then compare it to the target integer. Since this procedure is essentially the addition of

multiple elements, the time complexity of the oracle is .

By using the standard unitary transformation

the oracle flips the output register if represents the subset of elements whose sum is . By

quantum parallelism, applying one unitary transformation on a state vector is equivalent to

transforming all computational basis states, evidence already that is much

more efficient than the classical algorithm. However, this operation is still insufficient, as

must somehow distinguish the correct state from the incorrect ones, but this unitary

https://scholarcommons.usf.edu/ujmm/vol4/iss2/2 DOI: http://dx.doi.org/10.5038/2326-3652.4.2.2 Moon: The Subset Sum Problem: Reducing Time Complexity of NP-Completene 16 BO MOON

transformation leaves the input register invariant. One way to mark the desired element is to

apply a phase inversion to the computational basis state by multiplying its amplitude by

while leaving all other states untouched (Morsch). In order to accomplish this, consider the

Hadamard transform on the state ,

When a bit flip is applied,

which is equivalent to multiplying the qubit by . Upon further inspection of the output register

, if the oracle returns a , then the tensor product of the input and output registers

becomes negative, and it is left alone when the oracle returns . Thus, the unitary transform can

be rewritten as (Mermin)

A conceptual implementation of the oracle is now complete. As for its physical implementation,

it has been discussed previously that any quantum gate can be physically realized, so it will not

be of concern here.

2) The Grover Iteration: to be the equal superposition

state obtained by passing n qubits in the state through the Hadamard gate (Mermin):

Produced by The Berkeley Electronic Press, 2012 Undergraduate Journal of Mathematical Modeling: One + Two, Vol. 4, Iss. 2 [2012], Art. 2

THE SUBSET SUM PROBLEM: REDUCING TIME COMPLEXITY OF NP-COMPLETENESS WITH QUANTUM SEARCH 17

Next, the state vector is passed through the standard unitary transformation with in

the input register and in the output register, applying a phase inversion to the amplitudes of

the desired computational basis states:

As discussed earlier, the ancillary qubit is tensored with the input register in order for the

phase inversion to work properly; however, since this particular qubit is not required for any

since the unitary transform indicates a proper tensor product between the input and output

registers, the state vector does not suffer from entanglement, so a measurement can be taken

regardless of the presence of .

Afterwards, a quantum gate is applied, where is the controlled phase

gate (Nielson and Chuang). The action of is to invert the phase of every computational basis

state save for , which can be described by (Nielson and Chuang). The net

effect of applying Hadamard transforms before and after the controlled phase gate allows for

to be rewritten as the diffusion matrix (Nielson and Chuang)

where is the equal superposition state that remains invariant within the gate. Essentially, the

diffusion matrix represents the inversion about the mean operation (Grover). For any given

amplitude of a computational basis state and the mean of all amplitudes , the amplitude is

below the mean by exactly . The diffusion matrix replaces the amplitude with a new

quantity that is above the mean by the same amount that was below the mean, or

thereby inverting the amplitude of the state about the mean (Morsch).

https://scholarcommons.usf.edu/ujmm/vol4/iss2/2 DOI: http://dx.doi.org/10.5038/2326-3652.4.2.2 Moon: The Subset Sum Problem: Reducing Time Complexity of NP-Completene 18 BO MOON

The inversion about the mean operation is essential for the magnification of the desired

amplitude and hence the probability of correct output. Since the oracle function inverted the

phase of the desired state, it is farther below the mean amplitude compared to the other

amplitudes. After applying the diffusion matrix, the desired amplitude will be farther above the

mean than the other amplitudes, which will have decreased. For example, in Figure 1, the

amplitudes of four different states are represented by vertical bars, and C is the farthest away

from the average line due to its inverted phase. However, after the inversion about the mean

operation, the amplitudes are above the mean by exactly the same amount they were once below

it; since C was the farthest below, it now becomes the farthest above.

Figure 1: The inversion about the mean operation on the amplitudes of four states (Grover).

The oracle function and the inversion about the mean operation together constitute the

Grover iteration, the part of the algorithm that must be repeated several times in order to improve

probability of success. As such, the Grover iteration is applied repeatedly on the initial

input (Mermin). Figure 2 demonstrates the results of the first Grover iteration on

the amplitudes of the computational basis states. For up to a certain number of iterations, the

amplitude of the desired state will continuously increase while the others approach . At this

point, a measurement is carried out to obtain one possible solution state , and due to repeated

use of G, the probability of observing a desired computational basis state is close to 1.

Produced by The Berkeley Electronic Press, 2012 Undergraduate Journal of Mathematical Modeling: One + Two, Vol. 4, Iss. 2 [2012], Art. 2

THE SUBSET SUM PROBLEM: REDUCING TIME COMPLEXITY OF NP-COMPLETENESS WITH QUANTUM SEARCH 19

Figure 2: Single call of the Grover iteration on the equal superposition state (Grover).

Since the Subset Sum Problem is not concerned with what particular subset is the

solution, for there could be multiple subsets, the final unitary transform is applied:

Simply measuring the output register will reveal whether is the correct solution: if the

measurement produces , then the state is correct, or else indicates a faulty solution.

3) Geometric Interpretation:

transformations acting upon vectors in space, providing a medium for deriving the time

complexity of this quantum algorithm. First of all, one must realize that the computational basis

is in fact an orthonormal basis of a Hilbert space, as any arbitrary state vector within the vector

space may be created with complex linear combinations of the computational basis states. Given

a computational basis of states, let there be possible solutions to the Subset Sum Problem.

Furthermore, let be the set of all computational basis states and B be the subset representing all

desirable states. Two new vectors can be created with linear combinations of the vectors in and

its complement (Nielson and Chuang):

https://scholarcommons.usf.edu/ujmm/vol4/iss2/2 DOI: http://dx.doi.org/10.5038/2326-3652.4.2.2 Moon: The Subset Sum Problem: Reducing Time Complexity of NP-Completene 20 BO MOON

In other words, is the linear combination of all undesirable states and is the linear

combination of all desirable ones, both of which have been normalized. Therefore, the initial

input state of equal superposition

can be rewritten as a linear combination of and , normalizing once more (Nielson and

Chuang):

Note that , and reside within the same vector space, as they are normalized and are

linear combinations of the basis vectors.

The computational basis states are orthonormal, as each is normalized and any pair of

vectors is orthogonal. Since and are linear combinations from disjoint sets of an

orthonormal basis, they are orthonormal as well. Consequently, and together span a

plane, forming the basis of a two dimensional Hilbert space. The most important corollary to this

realization is that state vectors may be rewritten as linear combinations of arbitrarily defined

computational basis states; that is, through a change of basis, qubits may be subjected to

measurement with respect to an entirely new yet equivalent basis (Nielson and Chuang). As a

result, it is fitting to describe the vectors , and as equivalent to

Produced by The Berkeley Electronic Press, 2012 Undergraduate Journal of Mathematical Modeling: One + Two, Vol. 4, Iss. 2 [2012], Art. 2

THE SUBSET SUM PROBLEM: REDUCING TIME COMPLEXITY OF NP-COMPLETENESS WITH QUANTUM SEARCH 21

where the column vectors for and are defined by Dirac notation. Therefore, the entire

quantum system can be considered to take place within a plane (Nielson and Chuang).

and are very nearly orthogonal, but and are entirely orthogonal, so

and are separated by a very small angle , which can be found by taking the inner product

(Mermin)

where the last approximation is highly accurate for large N by the Small Angle Approximation.

As shown in Figure 3,

result of which is a rotation. First, the unitary transformation with the oracle function reflects the

initial vector across because the phase inversion on reverses the direction of the

corresponding component in :

After , will be below , displaced a total of . Similarly, the inversion about the

mean operation reflects across , which happens to be equivalent to

in the first Grover iteration (Mermin). brings towards by , creating a net

rotation of radians for a new state . Therefore, each application of the Grover

iteration rotates the state vector towards , the superposition of all desirable states, by

(Nielson and Chuang). After enough iterations, the final state vector is extremely close to , so

the amplitude of is drastically decreased while the amplitude of experiences a

https://scholarcommons.usf.edu/ujmm/vol4/iss2/2 DOI: http://dx.doi.org/10.5038/2326-3652.4.2.2 Moon: The Subset Sum Problem: Reducing Time Complexity of NP-Completene 22 BO MOON

corresponding increase. By is close to one, and by

the original definition of being the linear combination of all desirable states, any one of those

is equally likely to appear.

Figure 3: Rotation of state vector in a two dimensional Hilbert space (not drawn to scale) (Mermin).

4) Time Complexity of the Quantum Algorithm:

until it is almost nearly to maximize the probability that one of the desirable states will

be selected, so an optimal number of iterations must be calculated. As mentioned before,

and are almost orthogonal, so the state vector must be rotated by approximately radians.

Since the Grover iteration rotates by radians each time, the quantum computer must apply

about times (Vazirani). In order to attain proper time complexity by order of growth

analysis, this quantity must involve the input size. From earlier,

so it follows that

or for a worst-bound case when ,

Produced by The Berkeley Electronic Press, 2012 Undergraduate Journal of Mathematical Modeling: One + Two, Vol. 4, Iss. 2 [2012], Art. 2

THE SUBSET SUM PROBLEM: REDUCING TIME COMPLEXITY OF NP-COMPLETENESS WITH QUANTUM SEARCH 23

(Grover).

DISCUSSION

Since classical and quantum computation differ fundamentally by the type of operations

carried out, the time complexity of quantum algorithms is conventionally written in terms of the

number of oracle calls rather than operations. The time complexity of the dynamic programming

algorithm given previously will also be converted in order to give an accurate comparison of

efficiency.

The dynamic programming algorithm does not use oracle calls, but it is still possible to

rewrite its order of growth with respect to the time complexity of the oracle. As discussed, the

oracle essentially sums elements in the list according to the bit string passed to it, so its

performance is . The number of linear time operations used by the dynamic programming

algorithm is , so oracle calls are required. However, uses

oracle calls, so it significantly outperforms the classical approach by a factor of , a

quadratic reduction in time.

algorithm: the runtime of a quantum search is the square root of the runtime of the analogous

classical search (Nielson and Chuang).

One of the most promising applications of quantum search is to resolve the exponential

time complexity that is characteristic of NP-

provides a quadratic improvement in speed, one may conjecture that an even faster quantum

algorithm, perhaps

https://scholarcommons.usf.edu/ujmm/vol4/iss2/2 DOI: http://dx.doi.org/10.5038/2326-3652.4.2.2 Moon: The Subset Sum Problem: Reducing Time Complexity of NP-Completene 24 BO MOON

algorithm is optimal, so the fastest time complexity of any search algorithm, classical or

quantum, is (Zalka). Moreover, the NP-complete class is defined to be a set of search

problems that reduce to one another, yet the fastest possible search algorithm is still exponential,

which severely diminishes the hope that NP-complete problems do have a polynomial time

solution. However, there exist several alternatives, though not promising, to consider.

It is widely believed that NP-complete problems are intractable because there is no

exploitable organization in the underlying structure of the search space (Nielson and Chuang). In

fact, it is precisely this property that makes certain classical deterministic algorithms so efficient;

polynomial time since the solution satisfies the greedy property of optimizing locally to optimize

globally. As such, it may be possible to expedite solutions to the NP-complete class by

reexamining the search space in novel ways. For example, the dynamic programming algorithm

for the Subset Sum Problem presented earlier runs in pseudopolynomial time by utilizing optimal

substructure and overlapping subproblems. Though this approach was not sufficiently fast, it

demonstrates that there could be some property of the Subset Sum Problem, and possibly the

entire NP-complete class, not yet observed that can be used as the basis of an even faster

algorithm.

Another possibility to consider is the application of reductions. Finding the prime

factorization of an integer is a famously hard problem (though not NP-complete) that has no

known polynomial time solution in the classical realm, but quantum computation offers one.

problem of identifying periodicity, which can be solved with the Fourier transform and some

number theoretic insights (Morsch). Similarly, reductions may help bring known polynomial

Produced by The Berkeley Electronic Press, 2012 Undergraduate Journal of Mathematical Modeling: One + Two, Vol. 4, Iss. 2 [2012], Art. 2

THE SUBSET SUM PROBLEM: REDUCING TIME COMPLEXITY OF NP-COMPLETENESS WITH QUANTUM SEARCH 25

time solutions to the NP-complete problems. Of course, the largest and most overwhelming

obstacle to this consideration by far is that for an NP-complete problem to reduce to P, it would

require the proof of , a puzzle that has eluded generations of computer scientists. Still,

much of computational complexity theory analyzes problems in respect to classical algorithms,

so perhaps reductions of the NP-complete class may be possible with advances in quantum

computation.

Since the search for a polynomial time algorithm for NP-complete problems is bleak,

other approaches must be used for the time b

algorithm is optimal and in fact has just been shown to solve the Subset Sum Problem, and since

all NP-complete problems reduce to one another, quantum search certainly works on the entire

complexity class. Therefore, it is not only feasible but also more efficient to apply quantum

search techniques on NP-complete problems, especially when exact solutions are required, rather

than relying on heuristics and approximation algorithms.

CONCLUSION AND RECOMMENDATIONS

The Subset Sum Problem remains part of the NP-

achieves a notable improvement in time complexity over any known classical algorithm.

Furthermore, by reductions and slight computational overhead, quantum search can be applied to

any instance of NP-completeness, evincing the possibility of diverse application across fields as

well, such as in primality testing or cryptography. Although the physical aspects of quantum

computers were not discussed in depth, they do present significant but definitely tractable

challenges for engineers. Nevertheless, it is exciting to consider that quantum computational

theory may yield in the near future new algorithms inconceivable in a classical domain yet

innovative and possibly revolutionary for all of computer science.

https://scholarcommons.usf.edu/ujmm/vol4/iss2/2 DOI: http://dx.doi.org/10.5038/2326-3652.4.2.2 Moon: The Subset Sum Problem: Reducing Time Complexity of NP-Completene 26 BO MOON

NOMENCLATURE

Symbol Description Big-O notation. For an algorithm with input data size and processing time , indicates that is bounded above by .

Ket; in Dirac notation, a column vector. If is a nonnegative integer, its binary form represents a tensor product of a sequence of and kets.

Vector representing the state of a quantum system; i.e. a complex linear combination of possible discrete states the unmeasured quantum system can assume. Defined in Dirac notation as the column vectors and respectively.

Bra; or a row vector.

Inner product between and .

Outer product between and .

Tensor product between and .

-fold tensor product of with itself.

XOR operator; i.e. bitwise addition modulo 2.

Produced by The Berkeley Electronic Press, 2012 Undergraduate Journal of Mathematical Modeling: One + Two, Vol. 4, Iss. 2 [2012], Art. 2

THE SUBSET SUM PROBLEM: REDUCING TIME COMPLEXITY OF NP-COMPLETENESS WITH QUANTUM SEARCH 27

REFERENCES

Berman, Gennady P., et al. Introduction to Quantum Computers. Singapore: World Scientific, 1999. 38, 85-86.

Dasgupta, Sanjoy, Christos H. Papadimitriou and Umesh Vazirani. Algorithms. Boston: McGraw-Hill Higher Education, 2008. 243, 297-298, 301, 307.

Grover, Lov K. "Quantum Mechanics Helps in Searching for a Needle in a Haystack." Physical Review Letters 79.2 (1997): 325-328.

Larson, Ron, Robert Hostetler and Bruce Edwards. Calculus. 8th Edition. Boston, MA: Houghton Mifflin Company, 2005.

Mermin, David N. Quantum Computer Science: An Introduction. Cambridge: Cambridge University Press, 2007. 1, 17, 24, 37-38, 89-94.

Morsch, Oliver. Quantum Bits and Quantum Secrets: How Quantum Physics is Revolutionizing Codes and Computers. Weinheim: Wiley-VCH, 2008. 96, 109.

Neapolitan, Richard E. and Kumarss Naimipour. Foundations of Algorithms: Using C++ Pseudocode. Sudbury: Jones and Bartlett Publ., 1998. 194.

Nielson, Michael A. and Isaac L. Chuang. Quantum Computation and Quantum Information. Cambridge: Cambridge University Press, 2000. 29, 62, 153, 249-253.

Rosen, Kenneth H. Discrete Mathematics and Its Applications. Boston: McGraw-Hill, 2003. 781.

Vazirani, Umesh. Chem/CS/Phys191: Qubits, Quantum Mechanics, and Computers. n.d. 24 June 2012 .

Viamontes, George F., Igor L. Markov and John P. Hayes. "Is Quantum Search Practical?" Computing in Science and Engineering 7.3 (2005): 62-70.

Zalka, Christof. "Grover's quantum searching algorithm is optimal." Physical Review A 60.4 (1999): 2746-2751.

https://scholarcommons.usf.edu/ujmm/vol4/iss2/2 DOI: http://dx.doi.org/10.5038/2326-3652.4.2.2