HomeData Structures

What is Enqueue Function in Dynamic Queue ?

What is Enqueue Function in Dynamic Queue ?
Like Tweet Pin it Share Share Email

Enqueue function in Dynamic Queue :Queue Data Structure, we can insert elements until queue becomes full. But once if queue becomes full, we can not insert the next element until all the elements are deleted from the queue.

Enqueue function in Dynamic Queue

void enqueue(){
if(start==NULL){
temp= new list;
cout<<"Enter Value: ";
cin>>temp->data;
temp->ptr=NULL;
start=temp;} else{
temp= new list;
cout<<"Enter Value: ";
cin>>temp->data;
temp->ptr=NULL;
temp1=start;
while(temp1->ptr!=NULL)
temp1=temp1->ptr;
temp1->ptr=temp;}}

Dequeue function in Dynamic Queue

void dequeue(){
if(start==NULL){
cout<<"Error!List is Empty"<<endl; }
else{
temp=start->ptr;
delete start;
start=temp;}}

Display function in Dynamic Queue

void show(){
if(start==NULL)
cout<<"List is Empty"<<endl;
else{ temp=start;
while(temp!=NULL){
cout<<temp->data<<endl;
temp=temp->ptr;}}}

Comments (0)

Leave a Reply

Your email address will not be published. Required fields are marked *