An Improved Quantum Search Algorithm
Amrita Mitra
Bangalore, India.
DOI: 10.4236/jqis.2025.154012   PDF    HTML   XML   75 Downloads   383 Views  

Abstract

If we have to search an unsorted database or solve an unstructured search problem, we can use a quantum search algorithm [1]. As of now, a quantum search algorithm like Grover’s algorithm [2] takes Ω( N ) time, where N is the size of the search space. This paper proposes an improved quantum search algorithm that yields the correct result in constant time with a high probability.

Share and Cite:

Mitra, A. (2025) An Improved Quantum Search Algorithm. Journal of Quantum Information Science, 15, 208-215. doi: 10.4236/jqis.2025.154012.

1. Introduction

Let’s say f:{ 0,1,2,,N1 }{ 0,1 } is a function. In the case of an unstructured database, the domain of the function represents the indices of the database. f( x ) can be 0 or 1. f( x )=1 indicates that x points to one index of the database that contains the element that satisfies the search criteria. In all other cases, f( x )=0 . Our purpose is to find the index x for which f( x )=1 .

2. The Proposed Quantum Algorithm

Let’s say N is the size of the search space. Let’s also assume that n= log 2 N . Therefore, the binary representation of an index needs a maximum n qubits.

For our proposed algorithm, we can use the quantum circuit as shown in Figure 1. The first n qubits contain all zeros. And the ancillary qubit contains a 1. A Hadamard gate is applied to the first n qubits. A Hadamard gate is also applied to the ancillary qubit. We get the following state as a result:

| ψ 1 = 1 N x=0 N1 |x ( |0|1 ) 2 (1)

Figure 1. Quantum circuit for the proposed quantum algorithm.

In our proposed algorithm, we use an oracle U f . If |x is given as input and |y is the ancillary qubit, then we get the following state on querying the oracle:

1 N x=0 N1 |x| yf( x ) (2)

is the addition modulo 2 operator. In our case, the ancillary qubit is 1, and one Hadamard gate is applied to it. Therefore, on querying the oracle U f , we get the following state [3]:

| ψ 2 = 1 N x=0 N1 |x | 0f( 0 )| 1f( 1 ) 2 = 1 N x=0 N1 ( 1 ) f( x ) |x ( |0|1 ) 2 (3)

For example, if N=4 , n= log 2 N=2 . In that case, the state | ψ 1 is going to be the following:

| ψ 1 = 1 N x=0 N1 |x ( |0|1 ) 2 = ( | 00+| 01+| 10+| 11 )( |0|1 ) 2 2 (4)

After querying the oracle, we will get the following state:

| ψ 2 = 1 2 x=0 3 ( 1 ) f( x ) |x ( |0|1 ) 2 (5)

Let’s consider f( x )=1 when x=0 . And in all other cases, f( x )=0 . Therefore, the state | ψ 2 is going to be the following in this case:

| ψ 2 = ( | 00| 01| 10| 11 ) 2 × ( |1|0 ) 2 (6)

Therefore, the first n qubits after querying the oracle are the following:

( | 00| 01| 10| 11 ) 2 (7)

We can now apply a quantum gate G on this state, so that the output of this gate G is | 00 . Please note that in our example, f( x )=1 when x=00 . For any other value of x , f( x )=0 .

| ψ 3 =| 00 (8)

If we measure | ψ 3 , we will get the index in the unsorted database that points to the entry that satisfies the search criteria.

3. Implementation of the Quantum Gate G

Let’s say M is a unitary matrix that implements the quantum gate G. In this section, we will attempt to determine the unitary matrix M.

Let’s say N is the size of the search space. The indices in the unstructured database are 0,1,,N1 . It will take n= log 2 N qubits to represent these N indices.

Let the indices in the unstructured database be x 0 , x 1 ,, x N1 . And let the corresponding values of f( x ) be y 0 , y 1 ,, y N1 .

For example, in our example, the binary indices in the unstructured database are 00,01,10,11 . The corresponding values of f( x ) are the following:

f( 00 )=1

f( 01 )=0

f( 10 )=0

f( 11 )=0

This indicates the value pointed to by the binary index 00 satisfies the search criteria, and all other values do not. As a result, the first n qubits after querying the oracle are the following:

( | 00| 01| 10| 11 ) 2 (9)

We want the output of the quantum gate G to be | 00 .

Let’s say the column vector X represents the first n qubits after querying the oracle.

X= 1 N [ x 0 x 1 x N1 ] (10)

In our example, X represents the following state:

( | 00| 01| 10| 11 ) 2 (11)

Therefore, in our example,

X= 1 N [ x 0 x 1 x N1 ]= 1 2 [ 1 1 1 1 ] (12)

Let the column vector Y represent the expected output.

Y=[ y 0 y 1 y N1 ] (13)

For example, in our example, the expected output is | 00 . Therefore, Y is the following column vector.

Y=[ 1 0 0 0 ] (14)

In other words, the unitary matrix M is applied to X, and we get the output Y.

MX=Y (15)

Therefore, if we assume g:{ 1,0,1 }{ 0,1 } to be a function that takes each element of X as input and gives the corresponding element of Y as output, then the following holds true:

g( 1 )=0

g( 0 )=1

g( 1 )=1

Therefore,

Whenx=1,g( g( x ) )=g( g( 1 ) )=g( 0 )=1 Whenx=0,g( g( x ) )=g( g( 0 ) )=g( 1 )=0 Whenx=1,g( g( x ) )=g( g( 1 ) )=g( 1 )=1 (16)

Therefore, g is a function for which g( g( x ) )=x . Therefore, g is an involution function. And the corresponding matrix M is an involutory matrix.

4. Properties of Matrix M

Property 1: M is a unitary matrix.

As M implements a quantum gate, M must be a unitary matrix [4]. For a unitary matrix U, the following holds true:

U * U=U U * =I (17)

In our case, M is a real matrix. Therefore,

M T M=M M T =I (18)

Property 2: M is an involutory matrix.

As M is an involutory matrix, we can write the following:

M= M 1 (19)

Therefore,

M 2 =M M 1 =I (20)

Property 3: M is an orthogonal matrix.

As M is a unitary matrix and an involutory matrix, we can write the following:

M T M= M 1 M=I=M M 1 =M M T (21)

Therefore,

M T = M 1 (22)

Therefore, M is an orthogonal matrix.

Property 4: M is a symmetric matrix.

As M is an orthogonal matrix, we can write the following:

M T M=I (23)

M T = M 1 (24)

As M is an involutory matrix, we can write the following:

M= M 1 (25)

Therefore,

M T =M (26)

Therefore, M is a symmetric matrix.

Based on the above properties, we will look for the value of the matrix M that is as close to X 1 as possible. As the value of M is not equal to X 1 for all values of N, the value of M is going to introduce an error term. We will discuss the error term in Section 6.

5. Finding the Value of M

Ideally, we are looking for a matrix M for which the following condition holds true:

X= 1 N [ 1 1 1 1 1 1 1 1 1 ] (27)

Y=[ 1 0 0 0 1 0 0 0 1 ]=I (28)

MX=I (29)

Therefore, M should be equal to X 1 . However, X 1 may not be a unitary matrix for all values of N. Therefore, we will try to find a unitary matrix M such that MX is as close to I as possible.

Let’s say,

M= X 1 +E (30)

MX=( X 1 +E )X=I+EX (31)

This EX is the error term.

Therefore, we will look for an N×N matrix M for which the following conditions hold true:

1) M M T = M T M=I .

2) M M 1 = M 1 M=I .

3) M T = M 1 .

4) det( M )=±1 as M is involutory.

5) M 2 =I .

6) The error term EX is minimum.

We observe the following:

X= 1 N ( 2IJ ) (32)

J= [ 1 1 1 1 ] N×N (33)

Using the Sherman-Morrison formula [5], we get the following:

X 1 = N 2 I N 2N4 J (34)

Let’s say M is the following matrix:

M= k 1 I k 2 J (35)

Using the Sherman-Morrison formula, we get the following:

M 1 = 1 k 1 I k 2 k 1 2 ( N k 1 k 2 1 ) J (36)

As M is a symmetric, unitary, and involutory matrix, we get the following:

M 1 =M

1 k 1 I k 2 k 1 2 ( N k 1 k 2 1 ) J= k 1 I k 2 J (37)

By comparing both sides, we get the following:

k 1 =1

k 2 = k 2 k 1 2 ( N k 1 k 2 1 )

k 2 = 2 N

M= k 1 I k 2 J=I 2 N J (38)

Here, I is the identity matrix, and J is a matrix with all entries equal to 1. Therefore, the diagonal entries of the matrix M are ( 1 2 N ) and the non-diagonal entries of M are 2 N . Given the value of N, these values can be computed in O(1) time. The value of M does not depend on a specific input.

6. The Error Term

As we discussed, the error term is EX . We observe the following:

X= 1 N [ 1 1 1 1 1 1 1 1 1 ]= 1 N ( 2IJ )

J= [ 1 1 1 1 ] N×N

M= X 1 +E

E=( M X 1 ) =I 2 N J( N 2 I N 2N4 J ) =( 1 N 2 )I( 2 N N 2N4 )J

EX= 1 N ( ( 1 N 2 )I( 2 N N 2N4 )J )( 2IJ ) (39)

7. Results

Let’s say N is the search space. n is the required number of qubits.

N= 2 n

If we calculate the values of M,X, X 1 ,E , and EX for different values of n , and take the determinant of the error matrix EX , we get the following Table 1:

Table 1. Determinant of the error term.

n

N= 2 n

det( EX )

3

8

−0.00020734564555665073

4

16

−7.629394531249957e−05

5

32

−5.758564428031929e−06

6

64

−9.081620849843095e−08

7

128

−1.89081434676154e−10

8

256

−2.4238765388563638e−14

9

512

−6.252713627319217e−20

10

1024

−6.562978374539346e−28

11

2048

−2.8990010884419623e−39

Please note that the output matrix Y is the following:

Y=MX=( I 2 N J )× 1 N ( 2IJ )= 1 N ( 2I+ N4 N J ) (40)

In other words, the diagonal entries of the output matrix Y will be the following:

1 N ( 2+ N4 N )= 1 N × 3N4 N = 3N4 N N (41)

And, the non-diagonal entries will be the following:

N4 N N (42)

Therefore, once we find the required matrix M, the first n qubits of the following state are applied to the corresponding quantum gate:

1 N x=0 N1 ( 1 ) f( x ) |x ( |0|1 ) 2 (43)

As output, we will obtain the index from which we can retrieve the positions of the elements in the subset that satisfy the search criteria, along with the error as stated above.

8. Conclusions

Until now, the time complexity of a quantum search algorithm is Ω( N ) where N is the size of the search space. This paper proposes a quantum algorithm that reduces this time complexity. The proposed quantum algorithm requires n qubits as input, where n= log 2 N , and one ancillary qubit. After measuring the n-qubit output of the quantum gate G implemented using the unitary matrix M, we get the index in the unsorted database that satisfies the search criteria with a significantly high probability.

Though the unitary matrix M corresponding to the quantum gate G is an N×N matrix, there are only two different values for elements of M. All the diagonal elements of M have the same value. All non-diagonal elements of M have the same value. Therefore, the matrix M can be constructed in O( 1 ) time.

Conflicts of Interest

The author declares no conflicts of interest regarding the publication of this paper.

References

[1] Pittenger, A.O. (2012) An Introduction to Quantum Computing Algorithms. Vol. 19, Springer Science & Business Media.
[2] Grover, L.K. (1996) A Fast Quantum Mechanical Algorithm for Database Search. Proceedings of the Twenty-Eighth Annual ACM Symposium on Theory of Computing, New York, 1 July 1996, 212-219.[CrossRef]
[3] Nielsen, M.A. and Isaac L.C. (2010) Quantum Computation and Quantum Information. Cambridge University Press.
[4] Horn, R.A. and Johnson, C.R. (2012) Matrix Analysis. Cambridge University Press.
[5] Wikipedia Contributors (2025) Sherman-Morrison Formula. Wikipedia, Wikimedia Foundation.

Copyright © 2026 by authors and Scientific Research Publishing Inc.

Creative Commons License

This work and the related PDF file are licensed under a Creative Commons Attribution 4.0 International License.