# Classical Computing vs Quantum Computing

**Introduction : **

The conventional method of computing is the most popular method for solving the desired problem with the estimated time complexities. Algorithms of searching, sorting and many others are there to tackle daily life problems and are efficiently controlled over time and space with respect to different approaches. For example, Linear Search has time complexity of O(n), Binary Search have (nlog2n). These all give a boom to software industries and other IT sectors to work for the welfare of the world.

**Basic Conventional Structure : **

Certainly, we use bits (either 0 or 1) for storing the information and with the help of these 2 bits, we calculate Giga to Tera to Petabytes of data and even much more with quite unparalleled efficiency. Now let’s go deep into it, Four classical Bits can be transformed in 2^{4} combinations i.e. 16 combinations as follows-

0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111

That’s 16 possible combinations, out of which we can use only one at a time. Our CPU calculates at average 2.4GHz, apparently, it looks like that all combinations are calculated simultaneously but of course they are distinct from each other and CPU calculate one at a time each combination. Although simultaneous calculation can be done by having more than 1 CPU in the machine and that’s is called as Multiprocessing but that’s a different thing. The fact is that our CPU calculates each combination one at a time. Here arises a big and advanced research question – can all of them be used simultaneously at once without having any multiprocessors?

## Quantum Computing

To answer this crazy question, Quantum Computing came into the picture. This computing technique makes direct use of distinctively quantum mechanical phenomena such as superposition and entanglement to perform the operation on the data. The basic and extraordinary idea for quantum computing is that in normal classical computers, bits are the basic smallest unit of information.

Quantum computers use **qubits (Quantum bits)** which can also be set up as 0 or 1 likewise the classical bits but the container of these bits are changed from transistors to **photons**. A Qubit can be among any 2 level quantum system, such as spin and a magnetic field, or a single photon. The possible states can be entitled as 0 or 1 as per the horizontal or vertical polarisation. Consequently, of Quantum World theory, qubit doesn’t have to be just one of those. it can be in any ratio of both the states at once. That merely called as **Superposition**.

.

**Application of Quantum Computing**

This can lead to a severe and groundbreaking foundation in the field of computer science. This helps to solve many unsolved or virtually solvable problems with the unified space and time complexities.

**Creating an Application for the dice having 8 sides**

To write the basic program using quantum computing we have setup environment for the machine. Follow the below steps for setting up the Environment :

- Signup for a Free API key for Forest. After Signing up the API ket will be mailed to you freely.
- Check whether you have Python 3.x installed. (Use
**python –version**). If version not updated then installed latest version from here) - Once you have Right version install, install pyquil using command
**pip install pyquil**

**Importing the required module : **

`from` `pyquil.quil ` `import` `Program ` `from` `pyquil.api ` `import` `QVMConnection ` `from` `pyquil.gates ` `import` `H ` `from` `functools ` `import` `reduce` ` ` `qvm ` `=` `QVMConnection() ` |

*chevron_right*

*filter_none*

>

**Important Note : **

- Generally, quantum is programmed in Forest using the program object.
- QVM actually provides the connection to the quantum virtual machine (QVM).
- H is the Hadamard Gate. It is basically used to randomize the roll of the dice.
- reduce is basically the library used for iterative and looping functionalities.

**Final Program : **

`from` `pyquil.quil ` `import` `Program ` `from` `pyquil.api ` `import` `QVMConnection ` `from` `pyquil.gates ` `import` `H ` `from` `functools ` `import` `reduce` ` ` `qvm ` `=` `QVMConnection() ` ` ` `dice ` `=` `Program(H(` `0` `),H(` `1` `), H(` `2` `)) ` ` ` `roll ` `=` `dice.measure_all() ` ` ` `res ` `=` `qvm.run(roll) ` ` ` `value ` `=` `reduce` `(` `lambda` `x,y: ` `2` `*` `x` `+` `y,res[` `0` `],` `0` `)` `+` `1` ` ` `print` `(` `"Dice returned value are "` `, value) ` |

*chevron_right*

*filter_none*

;

## Output

While printing the roll value we got some instructions set as Output : H 0 H 1 H 2 MEASURE 0 [0] MEASURE 1 [1] MEASURE 2 [2] These instruction sets are basically written in QUIL (Quantum Instruction Language)

## Recommended Posts:

- Fuzzy Logic | Set 2 (Classical and Fuzzy Sets)
- Difference between Soft Computing and Hard Computing
- Cyber Security in Cloud computing
- Quantum Computing - The Computing Technology of Tomorrow
- Who Will Win The Quantum Supremacy Debate: Google or IBM?
- Code Reverse Engineering - How To Reverse Engineer Your Expired Software
- How to vertically flip an Image using MATLAB
- Introduction to ROS (Robot Operating System)
- Demystify Autorun and Malwares
- ML | AutoEncoder with TensorFlow 2.0
- ML | Introduction to Transfer Learning
- Create Mirror Image using MATLAB
- Getting started with the Google Coral USB accelerator
- Applications of MATLAB

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.