Update appNew update is available. Click here to update.
About
Mangalmay Institute of Engineering & Technology 2023
My Stats
EXP gained
yellow-spark
7971
Level
6 (Specialist)
Community stats
Discussions
2
Upvotes
0
Know more
294
Total problems solved
258
Easy
34
Moderate
2
Hard
0
Ninja
Dec Dec Jan Jan Feb Feb Mar Mar Apr Apr May May Jun Jun Jul Jul Aug Aug Sep Sep Oct Oct Nov Nov

Current streak:

0 days

Longest streak:

26 days

Less

More

Achievements
3
Ronin
Topics
Arrays
Linked List
Strings
Discussions
Queue implementation using array
Interview problems

#include <bits/stdc++.h>  class Queue {    int *arr;    int Front;    int back;    int n = 1000;     public:    Queue() {        // Implement the Constructor        arr = new int[n];        Front = -1;        back = -1;    }

   /*----------------- Public Functions of Queue -----------------*/

   bool isEmpty() {        // Implement the isEmpty() function        if(Front == -1 || Front > back){            return true;        }        return false;    }

   void enqueue(int data) {        // Implement the enqueue() function        if(back == n-1){            return;        }        back++;        arr[back] = data;        if(Front == -1){            Front++;        }    }

   int dequeue() {        // Implement the dequeue() function        if(Front == -1 || Front > back){            return -1;        }                int ele = arr[Front];        Front++;        return ele;    }

   int front() {        // Implement the front() function        if(Front == -1 || Front > back){            return -1;        }        return arr[Front];    } };

profile
Ankit_021
Published On 04-Dec-2022
151 views
0 replies
1 upvotes