Skip to main content
Entropy logoLink to Entropy
. 2025 Dec 24;28(1):24. doi: 10.3390/e28010024

Nested Grover’s Algorithm for Tree Search

Andreas Wichert 1
Editor: Pan Zhang1
PMCID: PMC12839987  PMID: 41593931

Abstract

We investigate optimizing quantum tree search algorithms by employing a nested Grover Algorithm. This approach seeks to enhance results compared to previous Grover-based methods by expanding the tree of partial assignments to a specific depth and conducting a quantum search within the subset of remaining assignments. The study explores the implications and constraints of this approach, providing a foundation for quantum artificial intelligence applications. Instead of utilizing conventional heuristic functions that are incompatible with quantum tree search, we introduce the partial candidate solution, which indicates a node at a specific depth of the tree. By employing such a function, we define the concatenated oracle, which enables us to decompose the quantum tree search using Grover’s algorithm. With a branching factor of 2 and a depth of m, the costs of Grover’s algorithm are O(2m/2). The concatenated oracle allows us to reduce the cost to O(m·2m/4) for m partial candidate solutions.

Keywords: quantum tree search, Grover’s algorithm, heuristics, nested search

1. Introduction

We investigate the optimization of quantum tree search algorithms by employing a nested Grover Algorithm. We explore the implications of this approach and identify the resulting constraints. Our findings demonstrate the potential for enhanced results compared to previously developed Grover-based methods. Instead of adopting the hybrid divide-and-conquer methods that are predicated on quantum backtracking and quantum walk, as indicated in [1,2], we will proceed with the initial conception of a nested version of Grover’s nested search, as described in [3]. In a nested version of Grover search, the complete tree of partial assignments is expanded to a specific depth, and then a quantum search is conducted within the subset of partial assignments that have not yet been eliminated.

It is claimed that, for certain reasonable distributions of problems, the average complexity of the original nested version of Grover search [3] will be less than that obtained from Grover search. This claim is supported by references [1,3]. Building upon the initial concept of a nested version of Grover search, we will adopt a combinatorial approach to address the limitations inherent in the original work, as described in [3]. For simplicity, we assume that the tree is uniform and its size is known beforehand. We will demonstrate our approach on simple examples using Qiskit, see [4]. The main contributions of this paper are as follows:

  • We introduce the definition of a partial candidate solution and the contented oracles.

  • We analyze the constraints of the original Grover’s nested search as introduced in [3];

  • We introduce the iterative approach with a quadratic speedup in comparison to the original Grover’s algorithm;

  • We investigate the possibilities of dividing the original space into two disentanglement subspaces and the resulting consequences;

  • We introduce the concept of performing a permutation on a subspace and the corresponding constraint.

Our approach imposes specific constraints that elucidate the concepts of partial candidate solutions within the context of quantum tree search. This work provides the foundation for quantum artificial intelligence applications, including quantum problem-solving and quantum production systems.

2. Quantum Tree Search

In this section, we outline the application of Grover’s algorithm to the tree search problem. Nodes and edges in a search tree represent states and transitions between states [5]. The initial state is the root, and from each state, either B states can be reached or it is a leaf. From a leaf no other state can be reached. b represents the branching factor of a node, indicating the number of possible choices. A leaf can either be the goal of the computation or an impasse when there are no valid transitions to a succeeding state. Each node except the root has a unique parent node, which is called the parent. Every node and its parent are connected by an edge. Each parent has b children. If b=2 and the depth of the tree is m, each of the m questions has a yes/no reply and can be represented by a bit (as shown in Figure 1). The m answers are collectively represented by a binary number of length m.

Figure 1.

Figure 1

Search tree for b=2 and depth m=2. Each question can be represented by a bit. Each binary number (11, 10, 01, 00) represents a path descriptor m from the root to the leaf.

There are n=2m=bm possible binary numbers of length m. Each binary number represents a path from the root to a leaf. For each goal, a specific binary number indicates the solution. This binary number is called a path descriptor, since it describes a path from the root of the tree to the leaf, see Figure 2 with b=2 and depth m=5.

Figure 2.

Figure 2

Search tree for b=2 and depth m=5. Each question can be represented by a bit.

For a constant branching factor b>2, each question has b possible answers. The m answers can be represented by a base-b number with m digits. In a quantum computation, we can simultaneously represent all possible path descriptors. There is one path descriptor for each leaf off the tree. Using Grover’s algorithm, we search through all possible paths and verify whether each path leads to the goal state. This type of procedure is known as a quantum tree search [6]. For n=bm possible paths, the costs are (approximately) n=bm2, corresponding to the reduced branching factor bq=b.

Grover’s Algorithm

For a function o(x)

oξ(x)=1ifx=ξ0else (1)

we seek to identify the value of x representing a path descriptor for which o(x)=1, where x=ξ, the path descriptor leading to the solution. This task is equivalent to a decision problem with a binary answer: 1 indicating a successful search and 0 indicating an unsuccessful search. The instance x is the input to the problem.

Grover’s amplification algorithm implements exhaustive search in O(n) steps in an n-dimensional Hilbert space [7,8,9,10]. This algorithm is derived from the Householder reflection of the state |x of m qubits, where n=2m. Grover’s amplification algorithm is optimal for exhaustive search, as demonstrated by the lower bound Ω(n) established by [11]. One can prove that a better algorithm cannot exist [12,13]. It follows that using a quantum computer, NP-complete problems remain NP-complete. Grover’s amplification algorithm provides a quadratic speedup over classical computers, which would require n steps to solve the problem.

For k solutions and more than two qubits (m>2, n=2m) the number r of iterations is the largest integer

r=π4·2mk. (2)

The value of r depends on the relation of n versus k. For n=4 and k=1 we need only one rotation, and we also need only one rotation for

n4=k

to find one of the k solutions. The iterative amplification algorithm requires the value of k in order to determine the number of iterations. We can determine the value of k by the quantum counting algorithm [14,15,16].

Uniform distributions are essential for Grover’s algorithm. If the distribution is non-uniform, the algorithm may not function properly or require adaptation which leads to the same complexity O(n) [3,17,18,19]. Consequently, we cannot simply mark potential solutions by assigning higher amplitude values to speed up the search. For instance, an adapted algorithm for sparse distributions where the majority of amplitudes are zero must generate a uniform distribution for the unmarked sets, with the resulting complexity O(n) [17,18,19].

In our analysis in relation to the O notation O(nk) and for simplification, we will assume the approximate complexity of Grover’s algorithm as

2mk=nk. (3)

instead of using the accurate Equation (2).

3. Nested Grover’s Search

Is it possible to integrate nested Grover’s search techniques into the quantum tree search algorithm to enhance the search process? Can the nested Grover’s search be based on heuristic functions? A heuristic function μ(y) estimates the cheapest cost from a node to the goal. The local path descriptor y describes the path from the root to the node. Therefore, each node in the tree can be described by a local path descriptor. However, we cannot employ a heuristic function to generate a non-uniform distribution, as it does not confer any advantage in Grover’s search. Furthermore, we cannot compare branches represented by distinct path descriptors. This is also the reason why the min-max algorithm cannot be applied to quantum tree search in games. The reason for this is that distinct branches correspond to distinct superpositions, and these superpositions interact solely through interference.

3.1. Partial Candidate Solution

Within the context of quantum tree search, instead of employing a heuristic function μ(y), we will utilize the function h(y), which represents a partial candidate solution, and y denotes a path from the root to the corresponding node. In contrast to the heuristic function μ(y), which can mark multiple nodes, h(y) should exclusively mark a single partial solution that includes the node indicated by the path y.

3.2. Decomposition

The idea of saving the costs is based on the inequality that represents the decomposition of the Hilbert space H of dimension n=2m into subspaces L and U of dimension 2g and 2mg, see Figure 3. For the value g we assume

2g<m.

Figure 3.

Figure 3

The decomposition of the Hilbert space H of dimension n=2m into subspaces L and U of dimension 2g and 2mg. In our example, m=5 and g=2.

The costs of Grover’s algorithm for the quantum tree search algorithm are

2m=2g·2mg.

However, the costs associated with Grover’s algorithm for the quantum tree of each subspace would be significantly reduced to

2g+2mg

(see Figure 4) with

2g+2mg<2g·2mg, (4)

since

1<2g·2mg2g+2mg+1
1<(2g1)·(12mg)

because

1<(2g1),1<(12mg).

Figure 4.

Figure 4

The concept of cost savings is predicated on the inequality that decomposes the Hilbert space H of dimension n=2m into subspaces H=UL of dimensions 2g and 2mg, respectively. On the left side, the sum of the costs of Grover’s algorithm, with leaves for addition resulting in 2g+2mg, is represented. On the right side, the original costs of Grover’s algorithm are 2m=2g·2mg, corresponding to the multiplication operation.

3.3. Nested Grover’s Search and Entanglement

Following, alternatively, the idea that Grover should speed up the search on Hilbert space H of dimension n=2m, a set of v partial candidate solutions

h(k)(y)withk{1,2,,v}

is defined that acts on g lower qubits with

h(k)(y)=1ify=hk0else (5)

on the subspace L of dimension 2g, with y being a local path descriptor. Throughout the paper, we will employ the little-endian notation, which stores the least-significant byte at the smallest address. Qubits are represented from the most significant bit (MSB) on the left to the least significant bit (LSB) on the right (little-endian), similar to binary numbers or bit-string representation on classical computers. We illustrate the fundamental concept of nested Grover search through a simple SAT example, characterized by v=2, g=3, and m=5.

h(1)(y)=¬x3x2x1,h(2)(y)=x3¬x2,x1
y=x3,x2,x1;xk0,1,
o(x)=x5¬x4x3¬x2x1,x=x5,x4,,x1;
xk{0,1},

as indicated by the circuit in Figure 5a, with the results of measurement shown in Figure 5b. In the initial step, we determine the set using Grover’s algorithm on the subspace L. In the subsequent step, we anticipate utilizing this set to expedite the search for the solution indicated by the oracle oξ(x), which operates on m qubits. Grover’s amplification is applied to the subspace U defined by the upper mg qubits. However, due to entanglement, we are unable to employ Grover’s algorithm on the upper subspace U defined by mg upper qubits, as both subspaces L and U become entangled.

Figure 5.

Figure 5

(a) Circuit using Grover’s amplification representing oracles h(1)(y)=¬x3x2x1, h(2)(y)=x3¬x2x1 for lower qubits and the global oracle o(x)=x5¬x4x3¬x2x1. Note, qubits 3 and 5 are auxiliary qubits used in Grover’s algorithm to mark the solution. We will employ the little-endian notation as used in Qiskit, see [4]. Notation: H indicates Hadamard gate, X indicates NOT Gate, h1 and h2 oracle circuits that marks the solution in the auxiliary qubits. O represents the global oracle circuits and G Grover’s algorithm circuits. Composed quantum circuits are indicated dark red, quantum gates with colours orange and blue. (b) Due to the entanglement of the lower qubits with the upper qubits, the solution indicated by 10101 is indicated only approximately by 50%.

To comprehend the behavior we introduce concatenated oracles.

3.4. Concatenated Oracles

Concatenation is an associative operation but not a commutative operation. We use for the operation concatenation the specific symbol ‖. If we assume that x is represented by m bits with the notation

x=xm,xm1,xm2,x2,x1;xk{0,1},

then concatenation is often simply the placement of the binary numbers next to each other,

(xm,xm1,,xg)(xg1,,x1)=xm,xm1,,x2,x1

For example, for a binary number of 10 and 11 we get

10  11=1011.

We extend the concatenation for the oracle function

oξ(xm,xm1,xm2,x1)=
u(xm,xm1,,xg) l=(xg1,,x1). (6)

Using compact notation,

z=(xm,xm1,,xg),y=(xg1,,x1),
x=(xm,xm1,,xg)(xg1,,x1),
x=z  y,

and the oracle function

oξ(x)=u(z) l(y)

with

oξ(x)=1ifx=ξ0else
u(z)=1ifz=u0else l(y)=1ify=l0else (7)

solution being

ξ=u  l,

with u=u(z) being the upper part of the oracle function that acts on the upper qubits, describing the upper subspace U of the dimension 2(mg) and l=l(y) being the lower part of the oracle function that acts on the lower qubits, describing the lower subspace L of the dimension 2g with

o(x)=o(z,y)=u(z)  l(y).

Note that l(y) and u(z) do not indicate partial candidate solutions; they are exact copies of the oracle function, and it can be challenging to specify them precisely. Also, u indicates the path descriptor. An example is represented in Figure 6.

Figure 6.

Figure 6

Search tree for B=2 and depth m=5. With h1=011, h2=000, u=11, l=011 and ξ=01111. Bold lines denote the path to the solution. The dotted line represents the path to the partial candidate solution that does not lead to a solution. Upper-field circles signify partial candidate solutions, while the bold circle in the leaf signifies the solution, which is composed of h1=l and u.

In the case we constraint y values to some values hk with

y{h1,h2,,hv}

the constraint oracle can be expressed as l=hk with

o(x)=o(z,hk)=u(z)  l(hk).

3.5. Not Entangled Subspaces

Imagine we know uμ(z) that acts on the upper subspace U defined by (mg) lower qubits and given set of t partial candidate solutions that act on the subspace L defined by upper g qubits,

h(k)(y)withk{1,2,,v}.

If we apply both oracles and use Grover’s algorithm to each Hilbert space defined by the subspace L and U, the results are not entangled since both subspaces are not entangled. In the first step, we determine using Grover’s algorithm on the Hilbert space defined by the subspace L. In the second step, we determine u(z) using Grover’s algorithm on the upper qubits of the upper subspace U with

H=UL. (8)

If we measure both subspaces, we see that each solution in the lower subspace L defines a new combination of the one solution in the upper subspace U. One of the combination could correspond to the global solution of the space as described by the oracle oξ(x), however we do not know if this is the case.

For example in the preceding example we introduce with v=2 and g=3

h(1)(y)=¬x3x2x1,h(2)(z)=x3¬x2x1

and the oracle for the (53) upper qubits

u(z)=x5¬x4

as indicated by the circuit in Figure 7a, with the results of measurement shown in Figure 7b.

Figure 7.

Figure 7

(a) Circuit employing Grover’s amplification to represent oracles h(1)(z)=¬x3x2x1, h(2)(y)=x3¬x2x1 for lower qubits, and the oracle for the upper qubits u(z)=x5¬x4. When we measure, we are not guaranteed to obtain the solution ξ=o(x), since o(x) was not checked and the possible combinations may be not present. Notation: H indicates Hadamard gate, X indicates NOT Gate, h1 and h2 partial candidate solution circuits that marks the solution in the auxiliary qubit, u represents upper part of the oracle function circuit and G Grover’s algorithm circuits. Composed quantum circuits are indicated dark red, quantum gates with colours orange and blue. (b) Due to the combinatorial problem that results in our case, we yield two solutions with equal probability, corresponding to the number of partial candidate solutions, since (v=2) with 1vk=1v|u,hk=12·(|10011+|10101).

The approach can be broadly characterized as

1mg·zBm(1)u(z)·|z,1g·yBg(1)h(k)(y)·|y (9)
1mg·zBm(1)u(z)·|z1g·yBg(1)h(k)(y)·|y (10)

after applying Grover’s algorithm to subspace L

1mg·zBm(1)u(z)·|z1vk=1v|hk (11)

and the subspace U

|u1vi=kv|hk=1vk=1v|u,hk (12)

since both subspaces L and U are not entangled.

3.6. Entangled Subspaces

In original nested Grover’s search (see Section 3.3), after applying Grover’s algorithm to the subspace L we get

1mg·zB(mg)|z1vk=1v|hk (13)

both subspaces L and U are entangled because

|x=|z,y,
o(x)=o(z,y)=o(z,hk)=u(z)  h(k)(y)=u(z)  l(y),
1mg·1v·zB(mg)k=1v(1)o(z,hk)·|z,hk. (14)

Applying Grover’s algorithm to the subspace U results in the creation of entanglement.

1mg·1v·zuhkl|z,hk+1v|ξ. (15)

In our preceding example with v=2 (see Figure 5) after applying Grover’s algorithm to the subspace L

12·12·zB2k=12(1)o(z,h2)·|z,hk (16)
18·zB2(1)o(z,h2)·|z,h1+18·zB2(1)o(z,h2)·|z,h2 (17)
18·zB2|z,h1+18·zB2(1)o(z,h2)·|z,h2 (18)

After applying Grover’s algorithm to the subspace U we get

18·zB2|z,h1+12·|ξ. (19)

with the state

18·|00,h1+|01,h1+|10,h1+|11,h1+
18·|00,h2|01,h2+|10,h2+|11,h2,

After applying Grover’s algorithm to the subspace U we get

18·|00,h1+|01,h1+|10,h1+|11,h1+12·|ξ,

see Figure 5b. Grover’s algorithm operates on the initial two qubits (upper qubits). It operates on two subspaces of U, one for h1 and the other for h2. In the subspace defined by h1, there is no marking. In the other subspace, there is a marking. As a result of Grover’s amplification, the first subspace exhibits a uniform distribution, while the second subspace contains a marking indicating the solution. Each of the two subspaces defined by h1 and defined by h2 has a probability of being measured of 0.5. In the first subspace, the uniform distribution of each state is represented by 0.5/4=1/8=0.125. In the second subspace, the solution is represented by 0.5, as indicated in Figure 5b. The number of partial candidate solutions, denoted as v, is inversely proportional to the probability of measuring the solution, which is represented as 1/v. How can this problem be effectively addressed? Two potential solutions to this problem are the iterative approach and the idea of the disentanglement of the two subspaces L and U.

4. The Iterative Approach

With the set of v partial candidate solutions

h(k)(y)=hkwithk{1,2,,v}

and the global oracle oξ(x), we built a circuit with one possible could-be solution of the set and the global oracle. We determine in the first step one solution of one h(k)(y) using Grover’s algorithm on the subspace L, and in the second step we the global oracle oξ(x) acts on m qubits. Subsequently, we apply Grover’s amplification to the subspace U, which is defined by the upper mg qubits. Figure 8 indicates an example representing the decomposed search tree for v=4.

Figure 8.

Figure 8

Example for v=4. Determine the solution h1 by Grover’s algorithm on the subspace L. Verify if the solution indicated by the oracle oξ(x) exists. Repeat the procedure for h2,h3,h4. The bold line signifies the verification of the partial candidate solution.

If a solution exists, the subspaces L and U are not entangled with H=UL. In this case, by measuring H, we obtain the solution. This is because the number of partial candidate solutions represented in our circuit is “one,” v=1, and the probability of measuring a solution, if it exists, is 1/v=1. We measure the state and test whether a solution is present. If it is, we terminate the process; otherwise, we select another potential solution from the set . For the simple preceding SAT example with v=2 and g=3 and m=5 we get two circuits, see Figure 9.

Figure 9.

Figure 9

(a) Circuit using Grover’s amplification representing oracle h(1)(y)=¬x3x2x1 for lower qubits and the global oracle o(x)=x5¬x4x3¬x2x1. Notation: H indicates Hadamard gate, X indicates NOT Gate, h1 and h2 partial candidate solution circuits that marks the solution in the auxiliary qubits. O represents the global oracle circuits and G Grover’s algorithm circuits. Composed quantum circuits are indicated dark red, quantum gates with colours orange and blue. (b) Since the solution does not exist, when measuring we get the combination of h1 with all four possible combinations of the two upper qubits x5 and x6 with the probability 1/8. (c) The solution for a circuit ξ=u  l with l=h2. It is the same circuit as shown in (a), only h(1)(y) is replaced with h(2)(z)=x3¬x2x1.

4.1. Algorithm

Given set of v partial candidate solutions

h(k)(y)=hkwithk{1,2,,v}

and the global oracle oξ(x).

For k=1 to v:

  • 1.

    For the could-be solution h(k)(y)=hk build a circuit;

  • 2.

    Determine the solution hk by Grover algorithm on the subspace L;

  • 3.

    Verify if the solution indicated by the oracle oξ(x) exists;

  • 4.

    If solution exists success, exit the loop, otherwise, continue the loop.

Since both subspaces L and U are not entangled, if a solution exists, it is readily apparent. We measure the state and verify whether it is a valid solution. If it is a solution, we conclude the process. Otherwise, we select another partial candidate solution from the set .

4.2. Optimal Dimension

How can we choose an optimal dimension of the two subspaces U and L? The optimal dimension of the two subspaces results in the minimal costs represented by the minimum of the function

2m·(1a)+2m·awitha[0,1] (20)

which is equivalent to

em·(1a)+em·awitha[0,1]
a·em·(1a)+em·a=em·(1a)·m+em·a·m;a[0,1] (21)

with the solution

a=12.

4.3. Costs

Within the subspace U, the costs associated with Grover’s algorithm are 2m/2, while within the subspace L, the corresponding costs remain 2m/2. We need to verify the proposed solution leads to a global solution. Subsequently, we must repeat the procedure in the worst case v times, leading to the cost

v·2m/2+2m/2+1=v·2·2m/4+1 (22)

with the constraint for v that the cost are below 2m/2 with

v<n1/22·n1/4+1n1/4=2m/4. (23)

since n=2m. We observe that maximal possible value for v is approximately equal to the number of nodes located at one-fourth of the depth of the search tree. We can express the cost of iterative search it in O notation, given vm, as

O(v·n1/4)=O(logn·n1/4). (24)

5. Disentanglement of L and U

Can we disentangle the spaces L and U with H=UL by knowing the function u(z)? We test the global oracle oξ(x) over the whole space of dimension m that defines the Hilbert space n=2m. The test should not entangle both subspaces L and U. We rely on the assumption that ξ exists and can be decomposed as

ξ=u  l.

Knowing oξ(x), assuming the u(z) is correct and with set the task is to verify if

o(x)=o(z,hk)=u(z) l(hk)

is true. If it is true, then we can decompose after Grover’s algorithm on the subspace L

12m1v·zBmk=1v(1)o(z,hk)·|z,hk= (25)
12m1v·zBmhkl(1)o(z,hk)·|z,hk+(1)o(z,hk)·|ξ= (26)
12m1v·zBmhkl|z,hk12m1v·|ξ (27)

After Grover’s search on the subspace U, if true,

1v·|uhkl|hk+1v·|ξ= (28)
|u1vi=kv|hk

If not true, for v>2

1v2·|u1(v2)·2mzBm|z1vi=kv|hk

and for v=2

12mzBm|z1vi=kv|hk.

In the event that |u does not exist for any z

12m1v·zBmk=1v|z,hk=12mzBm|z1vk=1v|hk. (29)

Since we do not know which hk=l we have to test all combinations, but we can reuse the set once computed.

12m1v·zBmhkh1(1)o(z,hk)·|z,hk+12m1v·(1)o(z,hk)·|ξ
12m1v·zBmhkh2(1)o(z,hk)·|z,hk+12m1v·(1)o(z,hk)·|ξ
12m1v·zBmhkhv(1)o(z,hk)·|z,hk+12m1v·(1)o(z,hk)·|ξ= (30)
12m1v·zBmhkh1|z,hk12m1v·|ξ
12m1v·zBmhkh2|z,hk12m1v·|ξ
12m1v·zBmhkhv|z,hk12m1v·|ξ. (31)

After Grover’s algorithm on the subspace U,

1v2·|u+1(v2)·2mzBm|z1vi=kv|hk
|u1vi=kv|hk
1v2·|u+1(v2)·2mzBm|z1vi=kv|hk

and if u is not present we get a general superposition. We arrive at the decomposition

H=Uhkh1Uhkh2UhkhvL (32)

We have determined the correct hk(y) by measuring |u with a probability of approximately 1 in U. Subsequently, we can estimate the path descriptor hk=l using Grover’s algorithm on the subspace L. The probability measurement of 1v2 indicates that hk(y) does not equal l and does not constitute a valid solution. However, for v>4, it necessitates a substantial number of measurements to ascertain that the probability deviates from 1.

5.1. Example with v=2

Our previous example with v=2

12312·zB3(1)o(z,hk)·|z,h1+12312·(1)o(z,hk)·|ξ
12312·zB3(1)o(z,hk)·|z,h2+12312·(1)o(z,hk)·|ξ=
12312·zB3|z,h112312·|ξ
12312·zB3|z,h212312·|ξ.

After Grover’s algorithm on the subspace U we get the decomposition

H=Uhkh1Uhkh2L=Uh2Uh1L, (33)

with

123zBm|z12·|ξ+|u|h212·|h1+|h2=
123zBm|z12·|u|h1+|u|h212·|h1+|h2=
123zBm|z|u12·|h1+|h2.

Because of the equality |ξ=|u|h1 we know that h1(y) is correct and can estimate the path descriptor h1=l by Grover’s algorithm on the subspace L.

5.2. Costs

Within the subspace L, the cost associated with Grover’s algorithm is (2m/2/v). For v combinations in the subspace U, the corresponding cost is v·2m/2. Additionally, given hk, we need to determine the path descriptor hk=l by Grover’s algorithm in the subspace L. The complete costs are

2m/2v+2m/2+v·2m/2=2m/2·1v+1+v (34)

We can express the cost of iterative search in O notation, given that vm as before, with

O(v·n1/4)=O(logn·n1/4).

For 1<v, the actual costs are less than the cost of the iterative algorithm with

2m/2v+2m/2+v·2m/2<v·2m/2+2m/2+1 (35)
2m/2·1v+1<v·2m/2<v·2m/2+1 (36)
1v+1<v, (37)

and they are cheaper in relation to times.

times=v·2·2m/2+12m/2·1v+1+v, (38)

For v>4, a substantial number of measurements is necessary. A practical approach would be to select v=4, resulting in approximately 1.45 faster costs

times=8·2m/2+42m/2·5.51.45

compared to the iterative approach with v/4=v/v possible iterations.

Implementation

For the of v partial candidate solution functions that acts on g lower qubits on the subspace L

h(k)(y)withk{1,2,,v}

we introduce a flagk variable

h(k)(y)=1=flagkify=hk0=flagkelse (39)

and extend the upper oracle in relation to the flagk variable

u˜(k)(z)=1if(z=u)(flagk=1)0else (40)

For example, for the case l=hs, u˜(s)(z)=oξ(x). To determine a possible solution we have to measure v subspaces U.

For example, in the preceding SAT example with v=2 and g=3 we introduce the flagk variable

h(1)(y)=¬x3x2x1,h(2)(z)=x3¬x2x1
u(z)(k)=(¬x6¬x5x4)flagk
o(x)=¬x6¬x5x4¬x3x2x1

where oξ(x) corresponds to u(y)1. The decomposition

H=Uh2Uh1L,

is represented by the quantum circuit in Figure 10a.

Figure 10.

Figure 10

(a) Circuit employing Grover’s amplification to represent oracles h(1)(z)=¬x3x2x1, h(2)(z)=x3¬x2x1 representing the decomposition Uh2Uh1L. The subspace L is represented by the qubits 0–2, subspace Uh1 is represented by the qubits 4–6 and subspace Uh2 is represented by the qubits 8–10. Notation: H indicates Hadamard gate, X indicates NOT Gate, h1 and h2 partial candidate solution circuits that marks the solution in the auxiliary qubits. O represents the global oracle circuits and G Grover’s algorithm circuits. Composed quantum circuits are indicated dark red, quantum gates with colours orange and blue. Notation: H indicates Hadamard gate, X indicates NOT Gate, h1 and h2 partial candidate solution circuits that marks the solution in the auxiliary qubits. O represents the global oracle circuits, U upper part of the oracle function and G Grover’s algorithm circuits. Composed quantum circuits are indicated dark red, quantum gates with colours orange and blue. (b) We measure the subspace Uh1 representing the solution. (c) We measure the subspace Uh2 representing a non-solution.

6. Permutation in the Subspace L

We can map the set of solutions determined by the function of the set into in the subspace L into another ordering that uses only the corresponding subset that could lead to a decomposition. For example, the superposition

12·(|011+|101)

is mapped by a permutation matrix P

P·12·(|011+|101)=12·(|000+|001)=
|0012·(|0+|1) (41)

into the decomposition |0012·(|0+|1), see Figure 11.

Figure 11.

Figure 11

(a) After applying Grover’s algorithm, with two solutions indicated by h1(y) and h2(y). (b) Mapping by permutation operator P indicated by the gate “Unitary” of the register |y=12·(|011+|101) into |x=|0012·(|0+|1). Notation: H indicates Hadamard gate, X indicates NOT Gate, h1 and h2 partial candidate solution circuits that marks the solution in the auxiliary qubits. G indicates Grover’s algorithm circuits and Unitary the permutation operator P circuit. Composed quantum circuits are indicated dark red, quantum gates with colours orange and blue. (c) Measuring the circuit (a). (d) Measuring the circuit (b) representing P·12·(|011+|101)=|0012·(|0+|1).

We can represent the permutation matrix P as

11000000=0001000000000100001000001000000000001000010000000000001000000001·00010100.

The operation corresponds to the mapping by permutation operator P of a register |yk of m qubits into a register |xk of m qubits, of which the first g qubits are |0g, with

1vk=1vP·|yk=|0g1vk=1v|xk. (42)

Since Qiskit uses little-endian notation we indicate the inverse order by a permutation matrix P

P·12·(|011+|101)=12·(|000+|100)=
12·(|0+|1)|00 (43)

into the decomposition 12·(|0+|1)|00. We can represent the permutation matrix P, and due to little-endian notation we get

10001000=0001000001000000001000001000000000000100000010000000001000000001·00010100.

The operation corresponds to the mapping by permutation operator P of a register |yk of m qubits into a register |xk of m qubits, of which the last g qubits are |0g, with

1vk=1vP·|yk=1vk=1v|xk|0g. (44)

We can apply such a permutation operator P for a nested Grover’s algorithm for tree search, as indicated in Figure 12. Grover’s algorithm is applied on the qubits 2, 4 and 5.

Figure 12.

Figure 12

(a) The corresponding circuit; the permutation operator P is indicated by the gate “Unitary”. After applying Grover’s algorithm with two solutions indicated by h1(y) and h2(y), using the oracle on the original space 12·(|011+|101) to mark the solution and mapping P·12·(|011+|101)=12·(|0+|1)|00. Qubit 2 indicates the marked solution describing the subspace L by permuted values h1 and h2. Qubits 4 and 5 correspond to the subspace U. Grover’s algorithm is applied on the qubits 2, 4 and 5. We the transpose P to determine the solution by the oracle oξ(x) in the original space. This is quite elegant, but until now, there appears to be no straightforward method to ascertain the mapping represented by P. Notation: H indicates Hadamard gate, X indicates NOT Gate, h1 and h2 partial candidate solution circuits that marks the solution in the auxiliary qubits. O represents the global oracle circuits, G indicates Grover’s algorithm circuits and Unitary the permutation operator P circuit. Composed quantum circuits are indicated dark red, quantum gates with colours orange and blue. (b) Determining the correct solution in the original space.

6.1. Costs

Ignoring the costs of the permutation operator P with the preparation costs v by basis encoding in subspace L, as described by [20,21,22], the costs corresponding to the Grover’s algorithm applied to m/2+log2v qubits are

v+2m/2+log2v=v+2m/2·v. (45)

With the preparation costs 2m/2v using Grover’s algorithm in subspace L the costs are

2m/2v+2m/2+log2v=2m/2·1v+v (46)

in O notation, given vm, with

O(v1/2·n1/4)=O((logn)1/2·n1/4).

6.2. Permutation Operator P

There appears to be no straightforward method to ascertain the mapping represented by P. The permutation operator P is defined by the v paths hk to partial could-be solutions. Due to entanglement we cannot determine the operator P using hk(z) and the resulting hk paths. Due to entanglement we cannot determine the permutation operator P without knowing the hk paths that indicate which nodes indicate partial could-be solutions. Knowing the hk paths we can determine the permutation operator P by controlled not gates, see Figure 13a. Using the regularities, permutation operator P can be considerably compressed, see Figure 13c, leading to reduced costs.

Figure 13.

Figure 13

(a) Representation of the permutation operator P·12·(|011+|101)=|0012·(|0+|1) by controlled not gates. First we indicate the two paths hk in superposition by two flag qubits 4 and 5. We used the two flag qubits and the knowledge of the two paths h1,h2 to perform the permutation mapping. Knowing the permutation mapping, we disentangle the two flag qubits 4 and 5 by mapping them to zero. Notation: H indicates Hadamard gate, X indicates NOT Gate and is used in as well in controlled not gates, h1 and h2 partial candidate solution circuits that marks the solution in the auxiliary qubits. G indicates Grover’s algorithm circuit. (b) The correct mapping |0012·(|0+|1) without entanglement of the additional qubits 3, 4 and 5 that are mapped to 0. (c) A compressed representation of the permutation operator P.

Knowing hk paths defines distinct nodes of the same depth simultaneously. For instance, in the quantum search tree depicted in Figure 6, the two extended oracles would be o1(011,u) and o2(000,u), with g=3, and we would seek the solution u. This approach is appropriate for a tree search where we presume that certain nodes at a depth g signify potential solutions. Alternatively, we could implement the two extended oracles directly through a quantum circuit using concatenation.

7. Discussion

7.1. Partial Candidate Solution h(y)

Within the context of quantum tree search, instead of employing a heuristic function μ(y), we will utilize the function h(y), which signifies a potential solution, and y represents a path from the root to the corresponding node. In contrast to the heuristic function μ(y), which can mark multiple nodes, h(y) should exclusively mark a single potential solution for the node. A set of partial candidate solutions can be identified by determining their similarity or distance to the goal state. However, how can we pinpoint a single potential solution, a single partial candidate solution? One approach to achieve this is to introduce an additional constraint that narrows the set to a single function, denoted by hk(y). Such a constraint could, for instance, specify the possible position within a subtree, thereby reducing the set to a single function. It is important to note that this approach is highly probabilistic and may occasionally yield non-existent partial candidate solutions or values exceeding one. Additionally, we have to take care that v is a constraint, as indicated by the Equation (23). In addition, further research should investigate the partial candidate solution hk(y) function on examples, as indicated in the paper [5].

7.2. Generalized Quantum Tree Search

We must have prior knowledge of the depth m off the search tree. This constraint can be circumvented through iterative deepening. In an iterative deepening search, we progressively increase the search limit from one to two to three to four and continue until a goal is discovered. For each limit, a search is conducted from the root to the maximum depth of the search tree. Should the search prove unsuccessful, a new search is initiated with a deeper limit. During the iterative deepening search, states are generated multiple times [23,24]. The time complexity of an iterative deepening search is comparable to that of a search to the maximum depth [23]. A quantum iterative deepening search is equivalent to an iterative deepening search [6]. For each limit max, a quantum tree search is performed from the root, where max represents the maximum depth of the search tree. The potential solutions are determined through measurement.

For a non-constant branching factor, the maximal branching factor Bmax has to be used for the quantum tree search [6]. For the maximum value of Bmax, the quantum algorithm using qubit representation outperforms the classical tree search described by the effective branching factor b in the specified case

b>bq=Bmax. (47)

For a large number of instances with varying initial and goal states, the effective branching factor converges to the average branching factor for an uninformed tree search, as shown in [5].

Consider each branching factor as a potential local path. For a non-constant branching factor, the quantum tree search utilizes the maximal branching factor, denoted by Bmax. If, in a node ν, Bν<Bmax, only Bν are required, and BmaxBν local paths are not utilized. To address this limitation, we augment the path descriptor by repeating the paths. This approach ultimately leads to k solutions that converge to the effective branching factor, as demonstrated in [5].

8. Conclusions

A primary outcome of the investigation is that conventional heuristic functions are unsuitable for quantum tree search due to the inability to disentangle the subspaces utilized by Grover’s algorithm. Furthermore, the theoretical concepts of the potential permutations within the subspace L suggest that due to entanglement, we cannot determine the permutation operator P without knowing the paths that represent the values of the heuristic functions.

Consequently, only partial candidate solutions possess the capability to disentangle these subspaces. We assume the existence of a set of partial candidate solutions, denoted by , that can be determined, for instance, by their similarity to the goal state. We impose the constraint that within this set, only one maximal partial candidate solution, denoted by hk(y), identifies a potential solution. Each partial candidate solution of the set can be constrained to be valid only in a specific subtree. It is important to note that a partial candidate solution is not a position in the search tree itself, as its values are unknown and are determined by Grover’s algorithm and may occasionally yield non-existent partial candidate solutions or values exceeding one candidate solution.

With the existence of the partial candidate solution h(y), the iterative approach represents a considerable speedup with the costs

v·2m/2+2m/2+1=v·2·2m/4+1 (48)

We can express the cost of iterative search it in O notation, given vm, since n=2m as

O(v·n1/4)=O(logn·n1/4).

Combinatory approach with the possible existence of the upper oracle u(z) allows us to disentangle L and U using

H=Uhkh1Uhkh2UhkhvL

which speeds up the costs minimally.

The work suggests a novel direction based on a partial candidate solution rather than heuristic functions that are unsuitable for quantum tree search. All Qiskit (v2.2) examples are presented in a Jupyter Notebooks that can be freely downloaded at https://github.com/andrzejwichert/Nested-Quantum-Tree-Search (accessed on 16 December 2025).

Institutional Review Board Statement

The funders had no role in the study design, data collection and analysis, decision to publish, or preparation of the manuscript. This article does not contain any studies with human participants or animals performed by any of the authors.

Data Availability Statement

The data presented in this study are openly available in [Nested-Quantum-Tree-Search] at https://github.com/andrzejwichert/Nested-Quantum-Tree-Search (accessed on 16 December 2025).

Conflicts of Interest

The authors declare no conflicts of interest.

Funding Statement

This work was supported by national funds through FCT, Fundação para a Ciência e a Tecnologia, under project UIDB/50021/2020. The funders had no role in study design, data collection and analysis, decision to publish, or preparation of the manuscript.

Footnotes

Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

References

  • 1.Montanaro A. Quantum-Walk Speedup of Backtracking Algorithms. Theory Comput. 2018;14:1–24. doi: 10.4086/toc.2018.v014a015. [DOI] [Google Scholar]
  • 2.Rennela M., Brand S., Laarman A., Dunjko V. Hybrid divide-and-conquer approach for tree search algorithms. Quantum. 2023;7:959. doi: 10.22331/q-2023-03-23-959. [DOI] [Google Scholar]
  • 3.Cerf N.J., Grover L.K., Williams C.P. Nested quantum search and structured problems. Phys. Rev. A. 2000;61:032303. doi: 10.1103/PhysRevA.61.032303. [DOI] [Google Scholar]
  • 4.Qiskit-Contributors Qiskit: An Open-Source Framework for Quantum Computing. 2023. [(accessed on 16 December 2023)]. Available online: https://zenodo.org/records/8190968.
  • 5.Wichert A. Quantum Artificial Intelligence with Qiskit. CRC Press; Boca Raton, FL, USA: 2024. [Google Scholar]
  • 6.Tarrataca L., Wichert A. Quantum Iterative Deepening with an application to the Halting problem. PLoS ONE. 2013;8:e57309. doi: 10.1371/journal.pone.0057309. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 7.Grover L.K. STOC ’96: Proceedings of the Twenty-Eighth Annual ACM Symposium on Theory of Computing. ACM; New York, NY, USA: 1996. A fast quantum mechanical algorithm for database search; pp. 212–219. [DOI] [Google Scholar]
  • 8.Grover L.K. Quantum Mechanics helps in searching for a needle in a haystack. Phys. Rev. Lett. 1997;79:325. doi: 10.1103/PhysRevLett.79.325. [DOI] [Google Scholar]
  • 9.Grover L.K. STOC ’98: Proceedings of the Thirtieth Annual ACM Symposium on Theory of Computing. ACM; New York, NY, USA: 1998. A framework for fast quantum mechanical algorithms; pp. 53–62. [DOI] [Google Scholar]
  • 10.Grover L.K. Quantum Computers Can Search Rapidly by Using Almost Any Transformation. Phys. Rev. Lett. 1998;80:4329–4332. doi: 10.1103/PhysRevLett.80.4329. [DOI] [Google Scholar]
  • 11.Aharonov D. Ph.D. Thesis. Hebrew University; Jerusalem, Israel: 1999. Noisy Quantum Computation. [Google Scholar]
  • 12.Bennett C.H., Bernstein E., Brassard G., Vazirani U. Strengths and Weaknesses of Quantum Computing. SIAM J. Comput. 1997;26:1510–1523. doi: 10.1137/S0097539796300933. [DOI] [Google Scholar]
  • 13.Boyer M., Brassard G., Hoeyer P., Tapp A. Tight bounds on quantum searching. Fortschritte Phys. 1998;46:493. doi: 10.1002/(SICI)1521-3978(199806)46:4/5&#x0003c;493::AID-PROP493&#x0003e;3.0.CO;2-P. [DOI] [Google Scholar]
  • 14.Brassard G., Hoyer P., Tapp A. Automata, Languages and Programming. Springer; Berlin/Heidelberg, Germany: 1998. Quantum Counting. [Google Scholar]
  • 15.Brassard G., Hoyer P., Mosca M., Tapp A. Quantum Amplitude Amplification and Estimation. arXiv. 2000 doi: 10.48550/arXiv.quant-ph/0005055.quant-ph/0005055 [DOI] [Google Scholar]
  • 16.Kaye P.R., Laflamme R., Mosca M. An Introduction to Quantum Computing. Oxford University Press; New York, NY, USA: 2007. [Google Scholar]
  • 17.Ventura D., Martinez T. Quantum associative memory with exponential capacity; Proceedings of the 1998 IEEE International Joint Conference on Neural Networks Proceedings. IEEE World Congress on Computational Intelligence; Anchorage, AK, USA. 4–9 May 1988; pp. 509–513. [Google Scholar]
  • 18.Ventura D., Martinez T. Quantum associative memory. Inf. Sci. 2000;124:273–296. doi: 10.1016/S0020-0255(99)00101-2. [DOI] [Google Scholar]
  • 19.Tay N., Loo C., Perus M. Face Recognition with Quantum Associative Networks Using Overcomplete Gabor Wavelet. Cogn. Comput. 2010;2:297–302. doi: 10.1007/s12559-010-9047-2. [DOI] [Google Scholar]
  • 20.Trugenberger C.A. Probabilistic Quantum Memories. Phys. Rev. Lett. 2001;87:067901. doi: 10.1103/PhysRevLett.87.067901. [DOI] [PubMed] [Google Scholar]
  • 21.Trugenberger C.A. Quantum Pattern Recognition. Quantum Inf. Process. 2003;1:471–493. doi: 10.1023/A:1024022632303. [DOI] [Google Scholar]
  • 22.Diamantini M.C., Trugenberger C.A. Mirror modular cloning and fast quantum associative retrieval. arXiv. 2022 doi: 10.48550/arXiv.2206.01644.2206.01644 [DOI] [Google Scholar]
  • 23.Korf R.E. Depth-first iterative-deepening: An optimal admissible tree search. Artif. Intell. 1985;27:97–109. doi: 10.1016/0004-3702(85)90084-0. [DOI] [Google Scholar]
  • 24.Russell S., Norvig P. Artificial Intelligence: A Modern Approach. Prentice Hall; Hoboken, NJ, USA: 2010. Prentice Hall series in artificial intelligence. [Google Scholar]

Associated Data

This section collects any data citations, data availability statements, or supplementary materials included in this article.

Data Availability Statement

The data presented in this study are openly available in [Nested-Quantum-Tree-Search] at https://github.com/andrzejwichert/Nested-Quantum-Tree-Search (accessed on 16 December 2025).


Articles from Entropy are provided here courtesy of Multidisciplinary Digital Publishing Institute (MDPI)

RESOURCES