Queue Implementation using Arrays

Queue Implementation using Arrays

take U forward

3 года назад

126,103 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@SaddamKhan-oc5lt
@SaddamKhan-oc5lt - 27.11.2023 18:35

Striver Supremacy .

Ответить
@studybits1604
@studybits1604 - 20.09.2023 14:15

us

Ответить
@ishantrivedi5588
@ishantrivedi5588 - 25.08.2023 10:03

is this a circular queue?

Ответить
@lakshmiprasanna7058
@lakshmiprasanna7058 - 23.07.2023 14:25

Understood 💯💯💯

Ответить
@SaketAnandPage
@SaketAnandPage - 29.03.2023 20:25

Wouldn’t that be i%n instead of front %n

Ответить
@roopeshn3301
@roopeshn3301 - 12.09.2022 20:32

Understood

Ответить
@hitheshpk6030
@hitheshpk6030 - 31.08.2022 20:07

understood

Ответить
@sarthakbhatia7888
@sarthakbhatia7888 - 12.08.2022 21:54

```
class Queue {
int *arr;
int f, r, count, size;
public:
Queue(int maxSize = 5000) {
size = maxSize;
f = r = count = 0;
arr = new int[size];
}

bool isEmpty() {
return count == 0;
}

void enqueue(int data) {
if (count == size) {
return;
}
r = r % size;
arr[r] = data;
count ++;
r ++;
}

int dequeue() {
if (count == 0) {
return -1;
}
f = (f + 1) % size;
count--;
return arr[f-1];
}

int front() {
if (count == 0) {
return -1;
}
return arr[f%size];
}
};
```

Ответить
@payalkukreja6808
@payalkukreja6808 - 03.08.2022 07:12

U are the Best!!!

Ответить
@roughuse.jaiganesh
@roughuse.jaiganesh - 02.08.2022 10:02

understood.

Ответить
@anand_bhatu_
@anand_bhatu_ - 24.07.2022 21:29

every time i see your videos i feel so much motivated. THANK YOU....

Ответить
@nitishprasadkushwaha
@nitishprasadkushwaha - 23.04.2022 04:37

u are the bestttt

Ответить
@shivanshuverma1934
@shivanshuverma1934 - 18.02.2022 13:57

vector<int> q;

int front,rear,cnt,size;
// int *arr;
MyCircularQueue(int k) {
q = vector<int>(k,0);
front = 0,rear = -1,cnt = 0,size = k;
}

bool enQueue(int value) {
if(cnt==size) return false;
rear = (rear+1)%size;
q[rear] = value;
cnt++;
return true;
}

bool deQueue() {
if(cnt==0) return false;
front = (front+1)%size;
cnt--;
return true;
}

int Front() {
if(isEmpty()) return -1;
return q[front];
}

int Rear() {
if(isEmpty()) return -1;
return q[rear];
}

bool isEmpty() {
return !cnt;
}

bool isFull() {
return cnt==size;
}
please like if you find my code useful

Ответить
@satyampande684
@satyampande684 - 29.11.2021 23:12

understood!!

Ответить
@paragroy5359
@paragroy5359 - 30.09.2021 15:58

Nice explanation your videos are really good...please keep on making such videos.

Ответить
@anujrawat6304
@anujrawat6304 - 04.09.2021 18:06

Understood

Ответить
@manavshah7450
@manavshah7450 - 29.07.2021 11:56

Understood
Thanks!

Ответить
@harshalgarg1149
@harshalgarg1149 - 14.07.2021 20:41

Isn't this the implementation of circular queue?

Ответить
@utkarshgupta3869
@utkarshgupta3869 - 21.06.2021 20:11

Hello bhaiya,
I have one question... please reply...
I am a B.Sc(c.s) Student.
Please help me to know can I get a job(above 5 lpa).
I learnt enough C++ and completed DSA and going to start web development and also 3 star at codechef.
I can learn anything for job after Graduation.

Please help to me tell that can I get or I have to do MCA.

Ответить
@prathamvyas8342
@prathamvyas8342 - 14.06.2021 21:16

Bro your work is great but make some lightings proper and camera position like Anuj Bhaiya

Ответить
@ambermittal8174
@ambermittal8174 - 13.06.2021 17:43

Bhaiya maths physics chemistry bhaut weak kya engineering kar lu ga please tell

Ответить
@divyanikashyap1916
@divyanikashyap1916 - 13.06.2021 07:26

Raj bhaiya iam starting coding but iam really feeling it tough,can u guide me please?How can I contact u?

Ответить
@shivamehta6537
@shivamehta6537 - 12.06.2021 15:52

Striver bhai op 🙌

Ответить
@roopasr6234
@roopasr6234 - 12.06.2021 14:28

Can you please make a video on sleeping patterns for programmers?

Ответить
@mihirbhasin1970
@mihirbhasin1970 - 12.06.2021 09:30

Nice one bhai

Ответить
@himanshujain7014
@himanshujain7014 - 12.06.2021 07:37

Bhaiya kya bond wali company me jana chahiye to 2 saal ka bond sign karaye? With 4.5 lpa

Ответить
@vishalkharadevk
@vishalkharadevk - 12.06.2021 04:54

Bro hats off for your hard work….liked the video for your teaching style

Ответить
@himanshukashyap9422
@himanshukashyap9422 - 12.06.2021 03:09

Nycc videoo plzz upload more interesting concept

Ответить
@ananddash2256
@ananddash2256 - 11.06.2021 19:20

Bro book allocation wala vdeo acha tha

Ответить
@muditkothari2211
@muditkothari2211 - 11.06.2021 17:44

Aah how easily u make concepts easier !! Hats off !

Ответить
@KiranKumar-em9qy
@KiranKumar-em9qy - 11.06.2021 16:35

HI Striver, i guess there may be a mistake in the implementation for a corner case.
when the front or rear goes above the size n, it has to be reassigned back with modulo n, rather than keeping it like that.
fornt = (fornt +1) %n;
because in case if front reaches INT_MAX, it automatically resets to 0 which may give a wrong value, which isn't intended

Ответить
@motivationalquotes6581
@motivationalquotes6581 - 11.06.2021 16:13

If we follow dsa from x path and then practice sde sheet by striver bahiya enough to crack dsa part of any company

Ответить
@bikashchoudhury8628
@bikashchoudhury8628 - 11.06.2021 16:07

Your assumption get correct this teaching style is very understandable. I saw your this 1st video board with teaching and I liked this 👍👍

Ответить
@jacksparrow1316
@jacksparrow1316 - 11.06.2021 16:00

Understood sir. .🙏

Ответить
@ritugoyak7238
@ritugoyak7238 - 11.06.2021 15:59

Understood bro....White board pr aur ache se smj aa rha hai..💯

Ответить
@prithvichetty15
@prithvichetty15 - 11.06.2021 15:58

Thank you sir please stack and queues pura kar dena please 😅🙊

Ответить
@parthkabra8880
@parthkabra8880 - 11.06.2021 15:50

was waiting for this..

Ответить
@Sonukumar-um3cs
@Sonukumar-um3cs - 11.06.2021 15:38

Sir abhi kl hi to aaya tha ye video phir se kyo??

Ответить
@jasonbrody4618
@jasonbrody4618 - 11.06.2021 15:30

Thank you

Ответить