Circular Queue Implementation using Array | Queue in Data Structure | DSA-One Course #49

preview_player
Показать описание
Hey guys, In this video, We're going to implement Queue using Array and Circular Array.

🥳 Join our Telegram Community:

🚀 Follow me on:

💸 Use coupon code ANUJBHAIYA on GeeksforGeeks to avail discounts on courses!

Hashtags:
#anujbhaiya #dsaone

Tags:

circular queue
circular queue implementation
queue in java
queue using array
queue
anuj bhaiya
queue in data structure
circular queue using array
circular array
circular queue in data structure
queue data structure
queue implementation java
queue java
circular queue in java
queue implementation
queue implementation using array
anuj bhaiya dsa
circular queue in c
implement queue using array
circular queue and dequeue
implementation of queue using array
circular queue in c++
linear queue
queue in c
circular queue java
stack and queue in data structure
array in data structure
circular queue
circular queue implementation
queue in java
queue using array
queue
anuj bhaiya
queue in data structure
circular queue using array
circular array
circular queue in data structure
queue data structure
queue implementation java
queue java
circular queue in java
queue implementation
queue implementation using array
anuj bhaiya dsa
circular queue in c
implement queue using array
circular queue and dequeue
implementation of queue using array
circular queue in c++
linear queue
queue in c
circular queue java
Рекомендации по теме
Комментарии
Автор

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.

saritaprasad
Автор

2 ghante se utube pr bhatak rha tha, thank u sir❤

RahulYadav-rlqd
Автор

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:

vector<int>ans;
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;
}
};

newtanagmukhopadhyay
Автор

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.

chandraprakashtiwari
Автор

Anuj bhaiya first viewer . Happy Diwali in advance 💣💣 you

GovindPanchal
Автор

🎯 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

aryanchauhan
Автор

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.

Misdaque
Автор

I was having problem implementing queue by circular array! as always saved us<3

oisheemajumder
Автор

Thanks brother, finally understood it!

ironbunz
Автор

Enjoying your videos and learning a lot. Preparation ho raha hh achaa placement k liye. Thanks Bhiaya ❤️

souravsaha
Автор

The Best Video On Circular Queue Ever ....

Bhaiyya you are the best ....

ece_a-_parthbhalerao
Автор

best part is how you give plenty of examples to make the code logic clear!!

prakhyat
Автор

Even though I don't know Java I could still follow your steps and wrote a code in C. Thank you for this video!

SipChai
Автор

Bhaiya Love u
Best Explanation
Thank you so much

anupn
Автор

Bhaiya ji.... Your teaching skills are great.... Simple and solid

SudhirSingh-mble
Автор

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.

harshitbansal
Автор

Sir please make a roadmap on cloud computing with original certification kha se le.

adarshkumar
Автор

Please bhiya make a complete detail video on c++.

aniruddhadas
Автор

Very good sir aur video banaoo btech ke liye

SPAxis
Автор

i am facing this problem to resolve circular queue now it is totally clear

vishalrichhariya