Posts

Showing posts with the label queue in java

Quantum Internet Benefits

Image
  The quantum internet is a network of quantum computers that are connected together using quantum communication. It has the potential to revolutionize many industries, including: Secure communications: The quantum internet would be inherently secure, as it would be impossible to eavesdrop on quantum communications without being detected. This could be used for applications such as secure financial transactions, government communications, and military applications. Quantum computing: The quantum internet would allow quantum computers to be connected together, which would allow them to solve problems that are currently impossible for classical computers. This could be used for applications such as drug discovery, financial modeling, artificial intelligence, and materials science. Quantum sensors: The quantum internet could be used to connect quantum sensors together, which would allow them to create a global network of sensors that could be used to monitor the environment, detect earthq

Data Structure and Algorithms : Queue Program in Java

Image
Program: public class queuepgm { private int maxSize; private long[] queArray; private int front; private int rear; private int nItems; public queuepgm(int s) { maxSize = s; queArray = new long[maxSize]; front = 0; rear = -1; nItems = 0; } public void enqueue(long j) { if(rear == maxSize-1) rear = -1; queArray[++rear] = j; nItems++; } public long dequeue() { long temp = queArray[front++]; if(front == maxSize) front = 0; nItems--; return temp; } public long peekFront() {     return queArray[front]; } public boolean isEmpty()       { return (nItems==0); } public boolean isFull() { return (nItems==maxSize); } public int size() { return nItems; } public static void main(String[] args) { queuepgm theQueue = new queuepgm(5); // queue holds 5 items theQueue.enqueue(10); theQueue.enqueue(20); theQueue.enqueue(30); theQueue.enqueue(40); System.out.println("Dequeue Values: FIFO"); while( !theQueue.isEmpty() ) { long n = th