Saturday, September 20, 2025

QUEUE

#include <iostream>
 using namespace std;
 #define MAX 100
 class QUEUE{
int front;
int rear;
int arr[MAX];
public:
QUEUE(){
    front=rear=-1;
}
bool isEmpty(){
    return (front==-1 && front==-1);
}
bool isFull(){
    return rear=MAX;
}
void enqueue(int value){
    if(isFull()){
        cout<<" queue overflow "<<endl;
        return;
    }
   if(isEmpty()){
    front=rear=0;
   }
   else{
    rear++;
   }
   cout<<arr[rear]<<endl;
}
void dequeue(){
    if(isEmpty()){
        cout<<" queue underflow "<<endl;
    }
    cout<<arr[front]<<" has been removed "<<endl;
    if(front==rear){
        front=rear=-1;
    }
    else{
        front++;
    }
}
int peek(){
    if(isEmpty()){
        cout<<"stack underflow "<<endl;
        return -1;
    }
return arr[front];
}
void display(){
    if(isEmpty()){
        cout<<" stack is empty "<<endl;
        return;
    }
    for(int i=front;i<=rear;i++){
        cout<<arr[i]<<endl;
    }
}
 };
 int main() {
 //Write your C++ code here
 cout << "Hello, World!" << endl;
 return 0;
 }

No comments:

Post a Comment

list in c#

  using System ; using System . Collections . Generic ; class Program {     static void Main () {         // Write your C# code here  ...