Introduction to Queue Data Structure | C++ Placement Course | Lecture 24.1

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

very nice and precise explaination, ,, thank you so much didi...

JackCoderr
Автор

here's the code :)
#include <iostream>
using namespace std;
#define n 20
class queue{
int * arr;int back;
int front;
public:
queue(){
arr=new int[n];
front=-1;
back=-1;
}
void Enqueue(int x){
if (back==n-1){
cout<<"stack over flowed"<<endl;
return;
}
back++;
arr[back]=x;
if(front==-1){
front ++;
}
}
void Dequeue(){
if (front==-1||front>back){
cout<<"queue is empty";
}
front++;
}
int peek(){
if (front==-1||front>back){
cout<<"queue is empty";
}
return arr[front];
}
bool empty (){
if (front==-1||front>back){

return true;
}
return false;
}
};
int main(){
queue q;
q.Enqueue(5);
q.Enqueue(8);
q.Enqueue(9);
cout<<q.peek()<<endl;
q.Dequeue();
cout<<q.peek()<<endl;
return 0;
}

studytoon
Автор

Thank you sister. Your lecture helped me.

mudassirshoukat
Автор

Thanks a lot. You made programming easier for me

arifazaib
Автор

In pop operation first we have to reset the values of front and rear to -1.After that we have to increment the front otherwise the code will not work perfectly. See this
int pop()
{
int data;
//check empty or not
if (empty()) {cout << " empty" << endl;}
else {data=arr[front];}
if (front >= rear)//reset values back to -1 then increment the front
{
front = -1;
rear = -1;
}
else
{
front++;

}
return data;
}

hammadfaiz
Автор

Are yaar aache se samaj aaya hame 😌 apka dhanyavaad ☺

islamicTv-fxtx
Автор

Thank you so much di
I need this video

AmanSingh-rzrj
Автор

Goddamn this is good. I was skeptical at first about a free yt video but it fares much better than a lot of paid ones. Only issue was the mic was a bit loud at times and the case of checking if the queue is empty could be elaborated but otherwise it does a really good job of getting across what is necessary.

harshaaravala
Автор

Didi is so busy in shifting from apni kaksha to apna college that in the intro she said "welcome to apni kaksha" instead of apna college.
Apart from that you are a great teacher

rahulkumarsharma
Автор

Didi said '' welcome to apni Anybody noticed?

hustler
Автор

11:41 My man got popcorns even before getting the tickets for the movie XD

lenovoxcarbon
Автор

But bhaiya big big big thanks to you. You are above all ❤️

iemmadhav
Автор

Great way of conveying. One recomendation is that if you replace mic for recording audio then it would be much better because there is a lot of distortion in your mic

hassixmalik
Автор

This code is wrong at soo many levels, the most prominent one being, like here we have fixed length queue of 20, now in main function try to enqueue 15 times, dequeue 10 times, and then again try to enqueue 10 times, then you will understand that even when the queue seems empty it will output queue is full.
Basically the dequeue functions is wrong, it should be as following -
void dequeue(){
if (front==-1 || front>back) {
cout << "Queue is already empty" << endl;
return;
}
for (int i = front; i < back; i++) {
arr[i] = arr[i + 1];
}
back--;
// if queue becomes empty
if(front>back){
front = -1;
back=-1;
}
}
so that when you dequeue, it actually empties the queue for the dequeued values, and when all the enqueued values are dequeued, it resets front and back to -1.
hope It helps, i had to spend hours to find the problem and debug it for all the possible testcases.

raghavpatodiya
Автор

video is amazing like every video
your voice is also amazing .
but what happened with mic its super annoying ear burned

sushantphalke
Автор

Is it better to use return statement in if rather than if else?if y or n how

blazemates
Автор

9:31
//Ninja Technique to write empty() function...

bool empty()
{

return front == -1 || front > back;
}

shaileshhacker
Автор

Mam mic issue is super annoying.
Please take care of that next time.
Else video is very nice.

viveksingh_
Автор

A random girl named Neha after listening her name again and again on this course be like:
"Maine kya bigaada tha aapka"

soumikmukherjee
Автор

Ma'am don't know how to thank you, but Ma'am Really Thank You, literally
Aaj tak jo cheeg samajh nahi paaya tha wo bhi aapke samjhane se samajh gaya, Dhanyawad Maam
Aap Aise hi padhati raho, hum padhte rahe aur jaldi jaldi cheezo ko seekh ke aage badhte rahe Ma"am

AbhishekGupta-lwtb