Skip to content

Instantly share code, notes, and snippets.

@mirsahib
Created November 4, 2017 14:59
Show Gist options
  • Save mirsahib/4e9be4107ce216da254f22c7ab2c8dbe to your computer and use it in GitHub Desktop.
Save mirsahib/4e9be4107ce216da254f22c7ab2c8dbe to your computer and use it in GitHub Desktop.
Assignment_5
#include <iostream>
using namespace std;
class Queue{
private:
int Front;
int Rear;
int length;
int num_array[100];
public:
Queue(){
length=100;
Front = -1;
Rear = -1;
}
void enQueue(int element){
if(isFull()){
return;
}else if(isEmpty()){
Front++;
Rear++;
}else if(Rear+1==length){
Rear = (Rear+1)%length;
}else{
Rear++;
}
num_array[Rear] = element;
}
void deQueue(){
if(isEmpty()){
cout<<"List is Empty"<<endl;
}else{
Front = (Front+1)%length;
}
}
void display(){
}
bool isEmpty(){
if(Front == Rear)return true;
return false;
}
bool isFull(){
int full = ((Rear+1)-Front);
if(full == length)return true;
return false;
}
};
int main()
{
Queue myQueue;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment