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

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 ธ.ค. 2024

ความคิดเห็น • 71

  • @aryanchauhan3097
    @aryanchauhan3097 ปีที่แล้ว +2

    🎯 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

  • @saritaprasad4295
    @saritaprasad4295 2 ปีที่แล้ว +23

    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.

    • @adityakanoi8703
      @adityakanoi8703 8 หลายเดือนก่อน

      Bhai go and help him

  • @RahulYadav-rl7qd
    @RahulYadav-rl7qd 6 หลายเดือนก่อน +8

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

    • @RishitMohanty
      @RishitMohanty 3 หลายเดือนก่อน

      Tum zaror aur kuch hi Kar Rahe hoge😂

  • @GovindPanchal
    @GovindPanchal 3 ปีที่แล้ว +17

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

  • @chandraprakashtiwari6061
    @chandraprakashtiwari6061 ปีที่แล้ว +1

    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.

  • @ece_a-65_parthbhalerao8
    @ece_a-65_parthbhalerao8 2 ปีที่แล้ว

    The Best Video On Circular Queue Ever ....
    Bhaiyya you are the best ....

  • @newtanagmukhopadhyay4716
    @newtanagmukhopadhyay4716 2 ปีที่แล้ว +2

    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;
    }
    };

  • @souravsaha933
    @souravsaha933 3 ปีที่แล้ว +2

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

  • @oisheemajumder5423
    @oisheemajumder5423 2 ปีที่แล้ว +11

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

  • @anupn5945
    @anupn5945 ปีที่แล้ว +1

    Bhaiya Love u
    Best Explanation
    Thank you so much

  • @prakhyat2001
    @prakhyat2001 2 ปีที่แล้ว

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

  • @SudhirSingh-mb5le
    @SudhirSingh-mb5le 3 ปีที่แล้ว

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

  • @AkashGupta-rw4vm
    @AkashGupta-rw4vm 2 ปีที่แล้ว +1

    Amazing explanation 😃😃

  • @rajkumarm526
    @rajkumarm526 3 ปีที่แล้ว +1

    Thanks for wonderful explaination

  • @SipChai
    @SipChai 2 ปีที่แล้ว

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

  • @pushkarjagre7791
    @pushkarjagre7791 3 ปีที่แล้ว +1

    Anuj bhaiyya you are doing great work mate 🥳🥳

  • @88Conqueror
    @88Conqueror 4 หลายเดือนก่อน

    Thank you bhaiya🙏🏻

  • @ironbunz7223
    @ironbunz7223 4 หลายเดือนก่อน

    Thanks brother, finally understood it!

  • @PoorvikPatel
    @PoorvikPatel ปีที่แล้ว

    you came with video like goodness because you always saved us in the end of the day 😆😆🤣🤣👍👍👍👍

  • @Misdaque
    @Misdaque 2 ปีที่แล้ว +4

    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.

  • @arnabroy2995
    @arnabroy2995 ปีที่แล้ว

    Than you for the explanation ❤

  • @mindsoulvalley1900
    @mindsoulvalley1900 2 ปีที่แล้ว

    Awesome explanation bro.. subtitles helped me

  • @pratikvishwakarma1599
    @pratikvishwakarma1599 2 ปีที่แล้ว

    Very amazing explanation, Thanks a ton

  • @azeemali6865
    @azeemali6865 2 ปีที่แล้ว

    Thank you Sir...

  • @alokranjan3185
    @alokranjan3185 2 ปีที่แล้ว

    Thanks ❤ for this great explanation bhaiya

  • @abdulmajidshaikh300
    @abdulmajidshaikh300 3 ปีที่แล้ว

    very nice video by Anuj bhaiya

  • @anonbaba6816
    @anonbaba6816 3 ปีที่แล้ว

    Anuj bhaiya's #DSAOne be like-- kyu pde ho chakkar m koi nahi h takkar m 💕👍👍

  • @adityasharma-vk8fg
    @adityasharma-vk8fg 4 หลายเดือนก่อน

    thanku sir

  • @Naeem-u5s
    @Naeem-u5s 2 หลายเดือนก่อน

    good work

  • @harshitbansal8601
    @harshitbansal8601 2 ปีที่แล้ว +1

    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.

  • @prashantshukla6870
    @prashantshukla6870 3 ปีที่แล้ว +1

    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.

  • @vishalrichhariya5226
    @vishalrichhariya5226 2 ปีที่แล้ว

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

  • @GAMINGHUNT04
    @GAMINGHUNT04 2 ปีที่แล้ว

    thankyou anuj bhiyaa

  • @opkrchauhan_1
    @opkrchauhan_1 หลายเดือนก่อน

    This video is helpful😊😊😅😅😅😅❤❤❤❤🎉🎉🎉

  • @SPAxis
    @SPAxis ปีที่แล้ว

    Very good sir aur video banaoo btech ke liye

  • @abhishekpratapsingh9283
    @abhishekpratapsingh9283 3 ปีที่แล้ว

    I am having viva today for the same ques 😁 thanku bhaiya!

  • @adarshkumar1489
    @adarshkumar1489 3 ปีที่แล้ว +2

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

  • @rpsingh9340
    @rpsingh9340 2 ปีที่แล้ว

    Circular Queue is best

  • @aniruddhadas1651
    @aniruddhadas1651 3 ปีที่แล้ว +1

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

  • @mrityunjoybarman9098
    @mrityunjoybarman9098 3 ปีที่แล้ว

    Great

  • @tech_and_memes
    @tech_and_memes 2 ปีที่แล้ว

    Bhaiya your code for queue using array isn't getting accepted on GFG can we remove the for loop to reduce its time complexity?

  • @SohailHassan-k9p
    @SohailHassan-k9p 26 วันที่ผ่านมา

  • @gamemaster1399
    @gamemaster1399 3 ปีที่แล้ว +1

    Sir java ka full course kab layenge

  • @rajdeepsaha5362
    @rajdeepsaha5362 2 ปีที่แล้ว

    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]

  • @adimishra3046
    @adimishra3046 3 ปีที่แล้ว

    At 9:32 I literally started rubbing my eyes 😂😂

  • @Strange2309
    @Strange2309 ปีที่แล้ว

    how can we print queue elements

  • @itsyash9427
    @itsyash9427 2 ปีที่แล้ว

    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?

  • @shreyasnair7949
    @shreyasnair7949 3 ปีที่แล้ว +4

    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?

    • @codingwithadesh6935
      @codingwithadesh6935 3 ปีที่แล้ว

      None of them...

    • @shreyasnair7949
      @shreyasnair7949 3 ปีที่แล้ว

      @@codingwithadesh6935 then?

    • @codingwithadesh6935
      @codingwithadesh6935 3 ปีที่แล้ว +1

      He used pseudo code so everyone can relate with there language

    • @prashantshukla6870
      @prashantshukla6870 3 ปีที่แล้ว

      Bro i code in c++ i just come here to see logic of bhiaya ..
      Bhaiaya code is like write once and implement code anywhere 😂

  • @archittoshniwal8085
    @archittoshniwal8085 2 ปีที่แล้ว

    Sir, can circular linked singly linked list also be considered as Circular Queue ?

  • @allenjonesstyles6112
    @allenjonesstyles6112 2 ปีที่แล้ว

    In queue, decrement of rear is not possible , then how ???

  • @navniagarwal7962
    @navniagarwal7962 3 ปีที่แล้ว +1

    It's a very basic question but could someone please explain why we took void for enqueue and int for dequeue function ?

    • @ayushjhanwar226
      @ayushjhanwar226 3 ปีที่แล้ว +2

      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 (:

    • @ShivamMishra-fo1wx
      @ShivamMishra-fo1wx ปีที่แล้ว

      jhatu ho kya jab itna nhi pta aur dsa padhne aa gyi

  • @devvaghela5046
    @devvaghela5046 ปีที่แล้ว

    But sir haw to display it?

  • @shubhpatel1578
    @shubhpatel1578 3 ปีที่แล้ว +1

    Bhai dracko ak de do

  • @kingmaker9082
    @kingmaker9082 2 ปีที่แล้ว

    Can anyone tell me what are the disadvantages of Circular queue?

  • @satyammishra6356
    @satyammishra6356 3 ปีที่แล้ว +3

    First

  • @HRSDAGouravBana
    @HRSDAGouravBana 3 ปีที่แล้ว

    Sir please aap java k program bnane sikha do,, please sir i am in need

  • @davidwarner325
    @davidwarner325 3 ปีที่แล้ว

    how to print data in circular array if anyone know please share the code or explain it

  • @startupmindset7597
    @startupmindset7597 2 ปีที่แล้ว

    how 1%4 is 1 please explain

    • @abhishek-j7x4r
      @abhishek-j7x4r ปีที่แล้ว

      divide 1 one by 4,then what is the remainder dude?

  • @deepfumtiya2015
    @deepfumtiya2015 3 ปีที่แล้ว +1

    Can anyone please share c++ code for implementation using circular array ??

  • @uctin9409
    @uctin9409 2 ปีที่แล้ว

    he is just speaking english ?? i can understand what did he say😭

  • @Hanan_khan_pathan
    @Hanan_khan_pathan 2 หลายเดือนก่อน

    bc damag kharab kr dia rare or front ny

  • @vcs649
    @vcs649 ปีที่แล้ว

    wonderful explanation 👍