Skip to content

Commit

Permalink
Queue using array
Browse files Browse the repository at this point in the history
  • Loading branch information
WaderManasi committed Sep 5, 2020
1 parent 0700e7f commit a661e76
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Queue/QueueUsing_Array.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* The method push to push element into the queue */
void MyQueue :: push(int x)
{
arr[rear]=x;
rear++;
}

/*The method pop which return the element
poped out of the queue*/
int MyQueue :: pop()
{
//
if(front==rear)
{
front=rear=0;
return -1;
}
int a=arr[front];
front++;
return a;
}

0 comments on commit a661e76

Please sign in to comment.