Function for insert, Delete an item in the queue in data structure

Function for insert, Delete an item in the queue in data structure

इस पोस्ट मे हमने Function for insert, Delete an item in the queue in data structure के बारे मे बताया है की हम क्यू मे केसे डाटा insert तथा delete करते है

Function for insert an item in the queue

Void insert ( int item)

{

If (rear > maxsize)

{

printf(“Queue overflow”);

break;

}

Else

{

Rear = rear+1;

Queue [Rear]=item;

}

}

Delete element from the Queue:-

1 If front <0                                                   [check under flow condition]

Write Queue is empty and return

2 eles ; item =queue [front]                          ( remove element from front)

3 find new value of front

If (front == rear )                                                 ( checking for empty queue)

Set front =0 ; rear =-1;                                        ( re- initialize the pointer )

Else

Front = front +1;

Function for delete an item from the queue:-

Void delete ()

{

If (front<0)

{

Printf(“queue is empty “);

Break;

}

Else

{

Item = queue [front];

Front = front +1;

Printf(“item deleted= %d”,item);

}

}

 

Leave a Comment