Queue Data Structure in C++ Programming (using arrays) | All Queue Operations | Part - 2

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

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

  • @shubhambaranwal31
    @shubhambaranwal31 4 ปีที่แล้ว +106

    int count()
    {
    if(rear==-1 && front==-1)
    return 0;
    else
    return rear-front+1;
    }
    count should be like this otherwise without element also count will be 1.
    Well thank you sir

    • @SimpleSnippets
      @SimpleSnippets  4 ปีที่แล้ว +19

      Yes this seems correct. I will pin your comment Shubham, thank you for pointing this out ✌

    • @dibbyabarua9499
      @dibbyabarua9499 4 ปีที่แล้ว +6

      I checked if(isEmpty()) :3

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

      else
      is not required actually ...
      ~~
      if (rear==-1 && front==-1)
      return 0;
      return rear-front+1;
      This one ...

    • @UJJWALKUMAR-dg9mw
      @UJJWALKUMAR-dg9mw 3 ปีที่แล้ว +2

      @Jermaine Randall u both r everywhere so i m reporting u

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

      I also came here in the comments box to tell this issue

  • @AjayKumar-ju6sl
    @AjayKumar-ju6sl 4 ปีที่แล้ว +8

    At 14:07 it gives count 1 even if the queue is empty
    That's why first we have to check for isEmpty and return 0 if isEmpty is true.

  • @AnoopKumar-bk2us
    @AnoopKumar-bk2us 5 ปีที่แล้ว +23

    Today my search ends here about QUEUE...
    best explanation...
    !!! thanks !!!

    • @SimpleSnippets
      @SimpleSnippets  5 ปีที่แล้ว

      Thanks bro 😬 I'm glad you liked it ✌️ also please do share it with your friends bro 😊

  • @usamafiaz6964
    @usamafiaz6964 4 ปีที่แล้ว +33

    Love You Bruh. I'm in 3rd semester and studying Data Structures. Its Going Outstanding.

    • @SimpleSnippets
      @SimpleSnippets  4 ปีที่แล้ว +8

      Thats really great to know buddy🙏 Please support me by sharing the videos and our channel with your friends too. Thats the biggest help and support you can provide 😇

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

      foundation uni?

    • @KingKhan-lt4mn
      @KingKhan-lt4mn 3 ปีที่แล้ว +2

      @@minahilxbts5925 may be fast uni faisalabad campus

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

      @@KingKhan-lt4mn not fast because we have 6 digits after the branch character, just like mine

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

      Same to you

  • @A9Shows
    @A9Shows 5 ปีที่แล้ว +7

    Man; this is the best explanation I have ever heard in a TH-cam video

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

      Hehe thanks bro🤟 please do share the video with your friends too 😊

    • @A9Shows
      @A9Shows 5 ปีที่แล้ว

      @@SimpleSnippets sure

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

    bhai, apke is channel ko to 1Milllion subcribers hona chaiye, itne acche aur satik tareeke se koi DS padha v skta h, vishwas nhi ho rha h!!!!!!!!...m apka bhot bhot abhari hu, jo apne itne jatil vishayon ko v itne saral aur graphics se zariye itna accha banaya ki hm ubte tk nhi!!!!!please ap CS k baaki subjects ko v graphics k zariye padhaeyega (but free m, bhai :)), taki humara bhala ho....apko ishwar sada sukhi rakhe......
    -Apka ek subscriber....

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

      Thank you Samarth, aapka ye comment padhke bohot acha laga and motivation mila aur aise educational videos bananke liye. And ha aur bohot saare educational videos ye channel par upload hoti rahegi bilkul FREE. Please aap ye channel and videos aapke dosto main share karey. Yehi bada support rahega 🙏

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

    BEST DSA course ever on youtube love the way you teach!

  • @vijaysinghchauhan7079
    @vijaysinghchauhan7079 4 ปีที่แล้ว +5

    Rigorous explanation.
    I am satisfied.
    Thank you, Tanmay Sakpal.

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

    Hey Guys, if you want more such tech educational videos on this channel then please support me by subscribing to this channel & also share it with your friends as it helps me create more content just for you ✌

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

    Your series has been a blessing to me and my life. May God bless you.

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

    if(rear==-1 && front==-1)
    return 0;
    else
    return rear-front+1;
    for printing elements we can use this rather than printing those deleted 0's :)
    Thank You sir!

  • @albertd.bangura3794
    @albertd.bangura3794 3 ปีที่แล้ว +5

    You are the best when I think of clear and excellent explanation on TH-cam! Thank you for making these videos, and I will always support you by sharing your channel with my friends and mentees!

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

      Thank you so much Albert. Because of you and such amazing support from you I get motivated to make more such free & high quality educational for all of you👍❤️

    • @albertd.bangura3794
      @albertd.bangura3794 3 ปีที่แล้ว

      @@SimpleSnippets 💖

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

    My always go to channel for my degree is justtt simple snippets alwaysss..... Thank you brother💁🏻‍♀️

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

    Hand down! This is one of the best explanation on DS

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

    Way of teaching ufffff kirrakkk hai

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

    bro u are op wish u were getted me at the time of diploma till now i was be at the intermediate level of programmer

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

    Your contents are amazing💖. I'm thankful to you from my heart❤❤

  • @mananjagani2892
    @mananjagani2892 4 ปีที่แล้ว +6

    Your explanation is mind blowing. Through your videos i get to learn things in a single shot!
    I have one request - can you please make a video on linked list implementation of stacks and queues.

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

      Hello Manan, thank you so much for such a positive feedback. I am glad to hear that these videos are easy to understand for you. Please do share these videos and our channel with your friends too. Thats the biggest help and support. And talking about your request, yes I will cover this topic soon so hope you have subscribed and turned on the notifications ✌

    • @ketanahuja8939
      @ketanahuja8939 4 ปีที่แล้ว

      @@SimpleSnippets please make as soon as possible on stack implement using linklist

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

    Your channel is like finding an oasis in Sahara Desert..... Thanks for the great explanation and endless effort !!!

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

      Hehehe thank you so much Sharvari 🙏 this was a great comment 😬 please do share this channel so that others also find this oasis 😉😊
      Hope you are staying home & safe. Tc ✌️

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

      @@SimpleSnippets I hope you too are safe and sound at home. 😇

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

    22:10 Drawback of "queue"

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

    Simply a perfect channel for perfect programming!!! 👊 thanks alot brother❤️

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

      Glad you enjoy it! Please support me by sharing the videos and our channel with your friends too. Thats the biggest help and support you can provide 😇

    • @shapind
      @shapind 4 ปีที่แล้ว

      @@SimpleSnippets sure brother! 👊

  • @ankitapareek489
    @ankitapareek489 4 ปีที่แล้ว +9

    Awesome!!! DS and algo was never so easy for me.....I was always scared of these....But the way you explain things makes them seem so easy and fun!! Thank you so much dude for the great work! :)
    I've also recommended this channel to many people...And then they even thanked me for the recommendation and told how your channel saved them! xD xD xD

    • @SimpleSnippets
      @SimpleSnippets  4 ปีที่แล้ว

      I'm so glad! Thanks Ankita, means a lot 😇🙏

  • @subhashisbhowmik7
    @subhashisbhowmik7 4 ปีที่แล้ว +8

    keep it more simple @simple snippets
    #include
    using namespace std;
    int rear,front; int arr[5];int value;
    class queue
    { int front,rear;
    public:
    queue()
    {
    front=-1, rear=-1;
    for(int i=0;i

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

      Thanks for the display function

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

      its a lot easier , thanks

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

    Queue Concept and its operations are now clear,thanks Tanmay Bhai 😍👍👍🙌🙌

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

    Great Explanation!!
    Minor bug fixes:
    bool isFull()
    {
    if (r-f == size-1)
    {
    return true;
    }
    else
    {
    return false;
    }
    }
    int count()
    {
    if (r == -1 && f == -1)
    {
    return 0;
    }
    else
    {
    return (r - f) + 1;
    }
    }

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

    Awesome!!!! Understood everything..
    Thanks.

    • @SimpleSnippets
      @SimpleSnippets  5 ปีที่แล้ว

      Thanks amazing Yashwardhan. Glad to hear this. I hope you have subscribed to this channel & please share this video with your friends too. That will be the biggest help & support 😇

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

    I think this is better approach to display the queue
    void display(){
    if(isEmpty()){
    cout

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

    Best DSA explanation man

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

    Bro your way of speaking and fluency in English is wonderful...👍👌👏👏

    • @SimpleSnippets
      @SimpleSnippets  4 ปีที่แล้ว

      Thank you so much Sandeep. This is such a great compliment. Hope the video was good and easy to understand as well ?

    • @sandeepnayak6357
      @sandeepnayak6357 4 ปีที่แล้ว

      @@SimpleSnippets the video was wonderful bro...keep making such videos help us...👍👍👌...

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

    Following you since 20k subscribers you had ❤️

    • @SimpleSnippets
      @SimpleSnippets  4 ปีที่แล้ว

      Wow that's amazing to know buddy ✌️ grateful for your support always 👍

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

    Here is the change() function, if anyone is wondering how to implement it. I have tried to make it dynamic, but we can make our own adjustments.
    Code:
    void change()
    {
    int x = front;
    int y = rear;
    int z;
    if(isEmpty())
    {
    cout

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

    Thankyou so much....explained it so well.

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

    to understand dequeue operation better use this :
    void dequeue(){
    if(isEmpty()){
    cout

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

    Best explanation but in the count function it is (rear - front +1 ) but if both the rear and count are at -1 and -1 the count should be zero but it is 1..

    • @dhonddevameya2362
      @dhonddevameya2362 4 ปีที่แล้ว

      Well in that case we should add if else statement in count function to show the isempty condition(rear=front=-1).Then your problem will be solved.

  • @SudhanshuSingh-ew2fi
    @SudhanshuSingh-ew2fi 4 ปีที่แล้ว +4

    Why we cannot have peek operation in queue data structure?

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

      We can. Its just that it is not considered as a standard queue operation. In some cases it is. So its really on you how you implement ✌

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

    If you will take question it will be better 🙂

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

    Wow...now I know what is queue... 😌
    Thankyou sir...🙏🙏🙏

    • @SimpleSnippets
      @SimpleSnippets  5 ปีที่แล้ว

      That's great to know buddy 😁 please subscribe & share this channel with your friends yaa😊✌️

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

    bro you are the best

  • @ShaikSaleem786-gv9eq
    @ShaikSaleem786-gv9eq 9 หลายเดือนก่อน

    One doubt bhaiya kya hum enqueue nahi karsakthaa values koo after performing dequeue operation kyku ki waha phar zero hai naa

  • @engineersanaullahvlogs
    @engineersanaullahvlogs 4 ปีที่แล้ว

    best explanation sir you are the best i realy like it good sir keep it up you deserve the suscess insallah

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

      Many many thanks

    • @engineersanaullahvlogs
      @engineersanaullahvlogs 4 ปีที่แล้ว

      @@SimpleSnippets Most welcome sir i really liked your vedios very helpful seriously from islamabad pakistan

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

    in dequeue why we have written return x, i mean we dont need that x right. could the return type of dequeue be void??

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

      Good question, when you simply want to remove it you can keep it void, but if you want to use it somewhere, returning might be helpful 😇

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

    even if the queue is empty, the COUNT shows 1.
    Please correct that exception.
    .
    .
    Good work man!

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

      Thank you so much 😇

    • @akashkhairal
      @akashkhairal 5 ปีที่แล้ว +4

      Edit the code like this:
      int count()
      {
      if(front == -1 && rear == -1)
      return (rear-front);
      else
      return (rear-front+1);
      }
      Then your problem will be solved.

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

    i decide to shift all element to left after i dequeue.. and i think using front and rear more effective if the element are dynamic like linked list

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

    for the problem at the end when you remove items from the front of list, why can't you shift every item left one space so that your new front item will be at index 0; then the rear would be decremented by 1. Therefore, your rear==4 will return false because now is rear==3

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

      I was thinking the same thing but then how would the code look like? Could we use a for loop?

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

    When we dequeue all the elements how the rear and front go to -1 as there is no change in rear in the else part of the dequeue function. Whenever i dequeue all the elements i can not enter new elements in the queue so the queue becomes useless. Can you help me?

    • @RahulYadav-gd3tn
      @RahulYadav-gd3tn 4 ปีที่แล้ว

      to overcome this limitation, circular queue comes into picture

  • @classim3715
    @classim3715 4 ปีที่แล้ว

    If you add 3 element in the quee and then dénuée the first element you will have something like 0 56 34 0 0 and if you call the count function it will execute rear-front +1 which is =-1-(-1)+1=1 ;which is wrong because you still have 2 element not one so to fix this you can initialize int itemsnumber. to 0 and do for (int i=0;I

    • @classim3715
      @classim3715 4 ปีที่แล้ว

      My English is great but I hope you understand what i meant

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

    I have just used rear variable for the implementation I run in for loop I just make arr[rear]=0 and than decrement the rear In dequeue operation....it is correct? Else we must use the two variable to implement the queue operation

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

    Amazing explanation

    • @SimpleSnippets
      @SimpleSnippets  5 ปีที่แล้ว

      Thank you Anisha, please do subscribe & share the videos with your friends. Thats the biggest support you can provide to the channel 😇

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

    You are saving my 3rd semester. 🙈 🙈
    Thanks a lot. 👍
    Please make some videos on graphs also....
    I guess I didn't find them in Data Structure's play list....

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

    When we carry dequeue operation, should the elements shieft by one index towards the element which was dequeued?
    Like we have five elements
    10 20 30 40 50.
    And we carried dequeue
    Then 10 gets dequeued
    And the new sequence should be
    20 30 40 50 0
    Right?

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

      You can make that happen according to your needs. Generally its not how a very basic queue operates ✌

    • @dhonddevameya2362
      @dhonddevameya2362 4 ปีที่แล้ว

      @@SimpleSnippets ok.Thanks

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

    What if you want to make a queue of size value entered by the user?

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

    why do we use return in enqueue function in if(isFull()) where as enqueue function type is void and does not return any type. please help me understand it.

  • @snehapatil4677
    @snehapatil4677 4 ปีที่แล้ว

    Best explanation 💯💯

    • @SimpleSnippets
      @SimpleSnippets  4 ปีที่แล้ว

      Appreciate that! Please do share the videos and our channel with your friends if you want to genuinely support me & our channel!✌😇

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

    Nice code but if someone insert 0 in the queue and display it then the output will be just zeros and it may become confusing at that index whether element is inserted or is it empty position. While displaying 0 should be converted to null.

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

      You can add that functionality with some extra code ✌

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

    When we create methods it is in the responsibility of the user (programmer) to make good use of those methods. For example, since you implemented the isEmpty() and isFull() methods, it is better to use them (in main method) before calling the enqueue and dequeue and not use them inside methods.
    example
    in class
    /////////////////////////////////////////////////////////////
    void enqueue(int val)
    {
    if(front == -1)
    ++front;
    arr[++rear] = val;
    }
    /////////////////////////////////////////////////////////////
    int dequeue()
    {
    int val = arr[front];
    arr[front] = 0;
    if(front == rear)
    front = rear = -1;
    else
    ++front;
    return val;
    }
    //////////////////////////////////////////////////////////////
    in main()
    case 1:
    cout > value;
    if(!q.isFull())
    q.enqueue(value);
    else
    cout

  • @MithleshKumar-pr7ew
    @MithleshKumar-pr7ew 3 ปีที่แล้ว

    Very very thankful sir

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

    You are awesome😇

    • @SimpleSnippets
      @SimpleSnippets  4 ปีที่แล้ว

      That's great to know buddy, please do Subscribe to our channel as we have a lot tech educational content which you'll surely like. Also please do share our channel and videos with your friends too, that's the biggest help and support you can provide buddy ✌

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

    Thank bro 🙏🙌love 💘

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

    Can you please upload vedios on
    What is doubly ended Queue (Dqueue) and it's c++ implementation using linked list representation
    C++ implementation of Queue using circular linked list
    C++ implementation of Stack using linked list

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

      I have done stack using linked list and queue using linked list I guess. check the full course!

    • @khyatiyadav2873
      @khyatiyadav2873 4 ปีที่แล้ว

      Ok thankyou
      Then please make a vedio on Dqueue

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

    We can just use return (rear+1); for count

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

      That will only work correctly if you have not dequeued anything. Once you dequeue an the front idex moves from zero, (rear + 1) will give you a count that is more that what is in the queue

  • @AnandMishra-rt2rs
    @AnandMishra-rt2rs 11 หลายเดือนก่อน

    Sir can we use this code in turbo c++ ide ? Please answer

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

    Shouldn’t we advance the entire queue by one position when dequeue() method is invoked? That will make room for one more element in the queue to be added.

  • @AnkitKumar-xz4uh
    @AnkitKumar-xz4uh 3 ปีที่แล้ว +1

    when we enter count in empty queue then count value should be 0 but in this code count value is showing 1

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

      You can call isEmpty and return 0 if it is true to fix this

    • @AnkitKumar-xz4uh
      @AnkitKumar-xz4uh 3 ปีที่แล้ว

      @@christianclark1309 thanks dude

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

    Good explanation

    • @SimpleSnippets
      @SimpleSnippets  5 ปีที่แล้ว

      Thank you so much bro. I would request you to please share the video with your friends too 😁😊

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

    Amazing ❤️🇧🇩

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

    bool isFull()
    {
    if(rear==4 && front==0)
    return true;
    else
    return false;
    }
    If statement should be like that coz, after fully filling the array and doing dequeue... The front increases but not rear ... & Thus it's not actually full, still it shows FULL .. coz front = 1 and rear = 4 ...
    So in if statement, both conditions should be checked !!

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

    There is mistake in count function also...if we does not enqueue any value....count must be 0 but this will show 1 because in that case rear and front both are -1 and -1-1+1 is 1.....so put this case also in count function when front and rear are -1

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

      Yes agreed! This was a silly mistake from my side ✌

  • @abhimanyu6534
    @abhimanyu6534 4 ปีที่แล้ว

    Bhaii plz btao ki agr hame dynamically user se size lena h to kaise krenge 🙏🙏🙏😓😭😭

  • @kaushik7811
    @kaushik7811 4 ปีที่แล้ว

    Is there an option to replace 0 with null because if someone enqueue 0 then it will be confusing right. When he uses display function then it will show the empty ones which is 0 and his 0. So how to solve that issue.

  • @Zeeshanhaider-wo5bs
    @Zeeshanhaider-wo5bs ปีที่แล้ว

    Sir you are initializing the array indices with 0..... What if we want to add 0 in the queue it might be confusing that index has some value or is it empty?

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

    when we enqueue 5 items and then dequeue 1 item... it places 0 at that place...and then again if we enqueue 1 item it says queue is full ??? why???

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

    can you pls explain how to enter size of array dynamically instead of already keeping it as 5??

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

      int s ;
      int arr[s];
      and then you can take value of s ;
      cin>>>s ;

    • @joanjoshy1599
      @joanjoshy1599 4 ปีที่แล้ว

      @@dt8129 where should we include this code? Under private or public section?

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

      @@dt8129 better way is to use a pointer : int* ptr = new int[take input from user]

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

    Sir ,the only thing I didn't get is when we assign all values of array 0 .them why queue is empty??

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

      Yes Queue is filled with zeros but we have assigned front and rear as -1 therefore Queue is empty.

  • @erehuchiha303
    @erehuchiha303 4 ปีที่แล้ว

    What if we are having some of our array entries as zeroes.. it will just make confusion ? Any soln over it?

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

    Dequeue operation perform nai ho rha es code .any other code?

  • @duxstybrick2536
    @duxstybrick2536 4 ปีที่แล้ว

    I didn't see any particular use of variable front it just use to store 0?

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

    your tutorial is awesome. It will be more effective if you give the source code.

  • @mahesh-jg3zx
    @mahesh-jg3zx 5 ปีที่แล้ว +2

    Sir please 🙏🙏 🙏 do the video on queue abstract Data type

  • @adarshtripathi3199
    @adarshtripathi3199 4 ปีที่แล้ว

    in count function what if the queue is empty --> rear-front+1 would give wrong ans

  • @ahmedrizwan7155
    @ahmedrizwan7155 4 ปีที่แล้ว

    I think you should check your dequeue "else" block
    it should be
    [x=arr[rear];
    arr[rear]=0;

    rear--;] in order to established FIFO or LILO
    in your code it is currently performing FILO or LIFO(stack)
    Am I right or not bro??

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

    thanks so much man

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

    I have a ques why we don't have a change() function in queue?
    Request you for your answer

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

      Yes I have same doubt bhai✋

  • @fatimaiqra2169
    @fatimaiqra2169 4 ปีที่แล้ว

    if we initialize arr[i]=Null; in constructor ,is it correct?

  • @nabeehazahid9613
    @nabeehazahid9613 4 ปีที่แล้ว

    bu the display function, the address of the elements is also getting displayed after the elements . I am new to c++ plz help

  • @gizmoclardin2711
    @gizmoclardin2711 4 ปีที่แล้ว

    Do have a place where you share these codes?

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

      Visit his website , u will get it there

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

    So, I had a quick question. When is a queue full? I understood all the concepts and your video was AWESOME (as always haha)... but not being able to define if the queue was full or not made me think what a queue being full meant? I'd appreciate if you could let me know. Thanks and like you always say... Peace

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

      I didnt really get your question here. A queue is full when all the values in it are occupied. A simple queue also has one drawback when a queue is dequeued the front pointer moves one position ahead essentially reducing the size of the queue by 1 because the front of the queue has to be removed off so we do it by dereferencing(meaning the front pointer no longer points to it). This creates an issue where some space from the start gets wasted after every dequeue. Hence we have circular queue as well to tackle this issue. Check the circular queue video I think you will understand much better what I am trying to explain here ✌

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

      ​@@SimpleSnippets so my question is why we cannot define the is_full() func like this for a linear queue?
      isFull()
      {
      if(f==0 and r == (size(arr)-1))
      return true;
      else
      return false;
      }
      in the isFull() function?

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

      @@dibbyabarua9499 because we just can't add further entries because the last value is present so as to deal with this exception we checked the rear end as size-1. This can be solved with dequeue

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

      @@MasterPanda10998 I did it instead using a dynamic array or linked list... Which can grow or shrink base on the operation done on it. Peace.

  • @Mahesh-wr6uc
    @Mahesh-wr6uc 5 ปีที่แล้ว +2

    Bro kindly can you please make a vedio on queue by dynamic data structures

    • @SimpleSnippets
      @SimpleSnippets  5 ปีที่แล้ว

      Sure thing but will take time :-)

    • @Mahesh-wr6uc
      @Mahesh-wr6uc 5 ปีที่แล้ว

      @@SimpleSnippets ok bro

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

    Sir can you please upload quiz for your covered topics. Thank you

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

    thank you! :)

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

    i went to the site for this topic and in there is an error in the dequeue implementation

  • @homosapien7754
    @homosapien7754 4 ปีที่แล้ว

    What happens if I define all the functions inside the main() and not under the class?

  • @aroobamalik9067
    @aroobamalik9067 8 หลายเดือนก่อน +1

    nope in display i should be less then rear else it will display zeros
    void display() {
    if (isempty()) {
    cout

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

    Amazing

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

    sir you told about 1 drawback of a simple queue is that isFull() couldn't give the correct and when some elements were dequeued but I coded it like this which gives true only when a queue is full otherwise not
    bool is_Full(){
    if(last-head==4)
    return true;
    else
    return false;
    }
    please inform if it is wrong

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

      but you are teaching in an awesome way I love it and now I'm addicted to learning from only you

  • @namithamadhusudan7613
    @namithamadhusudan7613 4 ปีที่แล้ว

    int count(){
    if(rear == -1 && front == -1){
    return 0;
    }
    else{
    return (rear-front+1);
    }
    }
    I wrote this as count function and it is not working! can someone help?

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

    Why does my code says i use undeclared variable x? But your code runs smoothly

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

    int Dequeue() {
    if(!isEmpty()) {
    int x = arr[front];
    for(int i=0;i

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

    You made a mistake for dequeue method at else if (front == rear). arr[front] should set to 0 after dequeuing. See * below.
    int dequeue(){
    int x;
    if (isEmpty()){
    cout

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

    Bhai why dont you create change and delete method in the class.
    Is it means that these methods we cant use in the Queue data structure?🤔

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

    Count method has a bug.
    The first statement must be:
    if(isempty()) return 0;