🎯 Key Takeaways for quick navigation: 00:00: Introduction to implementing a queue data structure using arrays and understanding the FIFO principle. 01:00: Exploring the limitation of fixed-size arrays for implementing a queue and the need for a circular array. 03:05: Analyzing the time complexity of enqueue (O(1)) and dequeue (O(N)) operations in a standard array-based queue. 05:13: Detailed code explanation for implementing a queue using a standard array, handling capacity, and performing enqueue and dequeue operations. 09:35: Introduction to optimizing queue operations to O(1) using a circular array and the concept of moving front and rear pointers. 12:10: Explanation of how to check if a queue is empty or full in a circular array-based implementation. 13:49: Overview of how to perform dequeue (removing elements) and enqueue (adding elements) operations efficiently in a circular array-based queue. 15:27: Implementation of a circular array-based queue in code, including enqueue, dequeue, and handling overflow and underflow conditions. Made with HARPA AI
My father is a labor so that I can not afford prestigious education. But people like you I will never regret that I could not get good teacher and premium education.
Sir I am a student of ISC board and was having problem in implementing the dequeue and enqueue operation in circular queue, but the way you dry ran the whole logic uprooted all the doubts I was rooted with. Thanks a lot and lot sir.
great video, just a small mistake i spotted. while returning the front and back elements, we will check for whether the whole queue is empty as a whole or not instead of just check front =-1 or rear=-1 individually. this was the code while got me AC : class MyCircularQueue { public:
bool deQueue() { if(isEmpty()) return false; int res=ans[front]; if(front==rear)//means only one element remaining. { front=rear=-1; } else { front=(front+1)%size; }
return true; }
int Front() { if(isEmpty()) return -1;
int res=ans[front]; return res; }
int Rear() { if(isEmpty()) return -1; return ans[rear]; }
bool isEmpty() { if(front==-1 and rear==-1) return true;
return false; }
bool isFull() { //rear is just begind front, it means the size has been reached. if((rear+1)%size==front) return true;
You could have maintained the size of the elements being inserted in a variable and just checked whether it is equal to the length of the array or whether it is equal to zero in order to check the capacity.
Sir, Ur way of teaching is very amazing. But I don't know why you didn't get more likes and more comments on your videos. But I make sure one day your dsa course will more popular. I dont know whether you read this comment or not.
Happy Diwali in advance bhaiaya. Bhiaya hope you will add practice interview preparation challenge after you complete all the topics in DSA . Your course is so amazing bhaiaya.
Sir,Front ko aage na baraye phir bhi to ho sakta hain...I mean front is always pointing to the first element of the array and rear+1%n==front ,then queue is full and front is always = a[0] and if there is only one element the rear should always be a[0]
The void main() indicates that the main() function will not return any value, the int main() indicates that the main() can return integer type data. We are returning result or -1 in dequeue function (:
🎯 Key Takeaways for quick navigation:
00:00: Introduction to implementing a queue data structure using arrays and understanding the FIFO principle.
01:00: Exploring the limitation of fixed-size arrays for implementing a queue and the need for a circular array.
03:05: Analyzing the time complexity of enqueue (O(1)) and dequeue (O(N)) operations in a standard array-based queue.
05:13: Detailed code explanation for implementing a queue using a standard array, handling capacity, and performing enqueue and dequeue operations.
09:35: Introduction to optimizing queue operations to O(1) using a circular array and the concept of moving front and rear pointers.
12:10: Explanation of how to check if a queue is empty or full in a circular array-based implementation.
13:49: Overview of how to perform dequeue (removing elements) and enqueue (adding elements) operations efficiently in a circular array-based queue.
15:27: Implementation of a circular array-based queue in code, including enqueue, dequeue, and handling overflow and underflow conditions.
Made with HARPA AI
My father is a labor so that I can not afford prestigious education. But people like you I will never regret that I could not get good teacher and premium education.
Bhai go and help him
2 ghante se utube pr bhatak rha tha, thank u sir❤
Tum zaror aur kuch hi Kar Rahe hoge😂
Anuj bhaiya first viewer . Happy Diwali in advance 💣💣 you
Sir I am a student of ISC board and was having problem in implementing the dequeue and enqueue operation in circular queue, but the way you dry ran the whole logic uprooted all the doubts I was rooted with. Thanks a lot and lot sir.
The Best Video On Circular Queue Ever ....
Bhaiyya you are the best ....
great video, just a small mistake i spotted. while returning the front and back elements, we will check for whether the whole queue is empty as a whole or not instead of just check front =-1 or rear=-1 individually. this was the code while got me AC :
class MyCircularQueue {
public:
vectorans;
int front;
int rear;
int size;
MyCircularQueue(int k)
{
ans.resize(k);
front=-1;
rear=-1;
size=k;
}
bool enQueue(int value) {
if(isFull())
return false;
if(front==-1)
front=0;
rear=(rear+1)%size;
ans[rear]=value;
return true;
}
bool deQueue() {
if(isEmpty())
return false;
int res=ans[front];
if(front==rear)//means only one element remaining.
{
front=rear=-1;
}
else
{
front=(front+1)%size;
}
return true;
}
int Front() {
if(isEmpty())
return -1;
int res=ans[front];
return res;
}
int Rear() {
if(isEmpty())
return -1;
return ans[rear];
}
bool isEmpty() {
if(front==-1 and rear==-1)
return true;
return false;
}
bool isFull() {
//rear is just begind front, it means the size has been reached.
if((rear+1)%size==front)
return true;
return false;
}
};
Enjoying your videos and learning a lot. Preparation ho raha hh achaa placement k liye. Thanks Bhiaya ❤️
I was having problem implementing queue by circular array! as always saved us
Bhaiya Love u
Best Explanation
Thank you so much
best part is how you give plenty of examples to make the code logic clear!!
Bhaiya ji.... Your teaching skills are great.... Simple and solid
Amazing explanation 😃😃
Thanks for wonderful explaination
Even though I don't know Java I could still follow your steps and wrote a code in C. Thank you for this video!
Anuj bhaiyya you are doing great work mate 🥳🥳
Thank you bhaiya🙏🏻
Thanks brother, finally understood it!
you came with video like goodness because you always saved us in the end of the day 😆😆🤣🤣👍👍👍👍
You could have maintained the size of the elements being inserted in a variable and just checked whether it is equal to the length of the array or whether it is equal to zero in order to check the capacity.
Than you for the explanation ❤
Awesome explanation bro.. subtitles helped me
Very amazing explanation, Thanks a ton
Thank you Sir...
Thanks ❤ for this great explanation bhaiya
very nice video by Anuj bhaiya
Anuj bhaiya's #DSAOne be like-- kyu pde ho chakkar m koi nahi h takkar m 💕👍👍
thanku sir
good work
Sir, Ur way of teaching is very amazing. But I don't know why you didn't get more likes and more comments on your videos. But I make sure one day your dsa course will more popular.
I dont know whether you read this comment or not.
Happy Diwali in advance bhaiaya.
Bhiaya hope you will add practice interview preparation challenge after you complete all the topics in DSA .
Your course is so amazing bhaiaya.
i am facing this problem to resolve circular queue now it is totally clear
thankyou anuj bhiyaa
This video is helpful😊😊😅😅😅😅❤❤❤❤🎉🎉🎉
Very good sir aur video banaoo btech ke liye
I am having viva today for the same ques 😁 thanku bhaiya!
Sir please make a roadmap on cloud computing with original certification kha se le.
Circular Queue is best
Please bhiya make a complete detail video on c++.
Great
Bhaiya your code for queue using array isn't getting accepted on GFG can we remove the for loop to reduce its time complexity?
❤
Sir java ka full course kab layenge
Sir,Front ko aage na baraye phir bhi to ho sakta hain...I mean front is always pointing to the first element of the array and rear+1%n==front ,then queue is full and front is always = a[0] and if there is only one element the rear should always be a[0]
At 9:32 I literally started rubbing my eyes 😂😂
how can we print queue elements
Sir correct me if I am wrong but ....
Circular queue me toh ham elements rear se insert karte hain naki front se
Lekin aapne front se kyun kiye?
Hey guys I'm thinking of starting this dsa one course, this is first video im watching, is he doing the course in Java or cpp?
None of them...
@@codingwithadesh6935 then?
He used pseudo code so everyone can relate with there language
Bro i code in c++ i just come here to see logic of bhiaya ..
Bhaiaya code is like write once and implement code anywhere 😂
Sir, can circular linked singly linked list also be considered as Circular Queue ?
In queue, decrement of rear is not possible , then how ???
It's a very basic question but could someone please explain why we took void for enqueue and int for dequeue function ?
The void main() indicates that the main() function will not return any value, the int main() indicates that the main() can return integer type data. We are returning result or -1 in dequeue function (:
jhatu ho kya jab itna nhi pta aur dsa padhne aa gyi
But sir haw to display it?
Bhai dracko ak de do
Can anyone tell me what are the disadvantages of Circular queue?
First
Sir please aap java k program bnane sikha do,, please sir i am in need
how to print data in circular array if anyone know please share the code or explain it
how 1%4 is 1 please explain
divide 1 one by 4,then what is the remainder dude?
Can anyone please share c++ code for implementation using circular array ??
he is just speaking english ?? i can understand what did he say😭
bc damag kharab kr dia rare or front ny
wonderful explanation 👍