## 4 Methodology
Eventually, to determine the winning class based on winner-take-all property, \(M_{z}\) operator output only the winning class based on the value of the concurrence. The steps of the QCPNN algorithm are shown in Algorithm 1. According to step 1, the quantum system is initialized by three quantum registers, arranged as \(|inp,qn,uv\rangle\). In step 2, when an input pattern is presented to QCPNN algorithm via register \(|inp\rangle\), the competition process is performed by detecting the overlapping qubits between the register \(|inp\rangle\) and the register \(|qn\rangle\), by applying the \(CNOT\) gate followed by the negation quantum gate \(X\). Hence, the winning class, which is entangled with the matched pattern, is marked by entanglement via applying the Toffoli-gate \(T^{j+1}\) in step 3. This gate flips the state of the qubit \(|u\rangle\) to state \(|1\rangle\) if the winning class is \"1\", therefore, the state of the qubit \(|u\rangle=\sqrt{\frac{M-1}{M}}|0\rangle+\sqrt{\frac{1}{M}}|1\rangle\). On the other hand, the gate \(T^{j+1}\) leaves the state of the qubit \(|u\rangle\) with no effect if the winning class is \"0\", therefore, the state of the qubit \(|u\rangle=|0\rangle\). Figure 4: The circuit model of \(M_{z}\) operator using [PERSON] et al. [54] protocol for implementing the operator \(D\). Figure 3: The circuit model of [PERSON] et al. [54] protocol to measure the entanglement between two qubits defined by the state given by Equation (2). By feeding two copies of the state given by Equation (2) to this circuit model. The protocol applies a controlled-not (\(CNOT\)) gate between the qubits indexed by 2 and 4, respectively. The \(\sigma_{y}\) gate is applied on the third and fourth qubits and followed by the rotation gate \(R\), therefore the measurement process is performed on the four qubits. ```
For an input pattern \(inp\) do{ 1. Initialization Step: \(\left|\psi_{0}\right\rangle=\left|inp,qn,uv\right\rangle\). Here, the quantum system is initialized by three quantum registers \(\left|inp\right\rangle\), \(\left|qn\right\rangle\) and \(\left|uv\right\rangle\) of size \(n\), \(n+1\) and 2 qubits, respectively. The register \(\left|qn\right\rangle\) represents the memory register that holds the prototype patterns, while \(\left|u\right\rangle\) and \(\left|v\right\rangle\) are the states of the other qubits. The first \(n\) qubits of the register \(\left|qn\right\rangle\) store the M prototype patterns, and the last qubit stores the class of the associated pattern. The input pattern that has a set \(h\) of \(j\) elements, where (\(j\)\(\leq\)\(n\)) is presented to the network via the register \(\left|inp\right\rangle\). The set \(h\) contains the indices of the qubits that have well known values. Finally, \(\left|uv\right\rangle\) is a two-qubit control register which are initialized by state \(\left|00\right\rangle\). 2. Apply the competitive detection operator between the input register \(\left|inp\right\rangle\) and the prototype register \(\left|qn\right\rangle\) as follows: \[\left|\psi_{1}\right\rangle=\prod_{i\in h}X_{qn_{i}}CNOT_{inp_{i}qn_{i}}|\psi_ {0}\rangle.\] In this step, the \(CNOT\) gate is applied between each qubit \(i\in h\), of the resiter \(inp\) as a control qubit and the corresponding qubit \(i\) in the register \(qn\) as a target qubit. Then the negation gate \(X\) is applied on each qubit \(i\in h\) in the register \(qn\). 3. Apply the Toffoli gate between \(j+1\) qubits of the register \(\left|qn\right\rangle\) as control qubits and the qubit \(\left|u\right\rangle\) as target qubit as follows: \[\left|\psi_{2}\right\rangle=T_{\left(\prod_{i\in h}qn_{i}qn_{n+1}u\right)}^{j+ 1}|\psi_{1}\rangle.\] In this step, the Toffoli gate (\(T^{j+1}\)) is applied on \(j+2\) qubits, where the superscript \(j+1\) represents the number of control qubits. Toffoli gate (\(T^{j+1}\)) negates the qubit \(u\) if the state of each qubit \(i\) belongs to the \(h\) and the state of the qubit \(qn_{n+1}\) are in the state \(\left|1\right\rangle\). 4.