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
@SimpleSnippets4 жыл бұрын
Yes this seems correct. I will pin your comment Shubham, thank you for pointing this out ✌
@dibbyabarua94994 жыл бұрын
I checked if(isEmpty()) :3
@joseph20733 жыл бұрын
else is not required actually ... ~~ if (rear==-1 && front==-1) return 0; return rear-front+1; This one ...
@UJJWALKUMAR-dg9mw3 жыл бұрын
@Jermaine Randall u both r everywhere so i m reporting u
@altamish_turk2 жыл бұрын
I also came here in the comments box to tell this issue
@SimpleSnippets5 жыл бұрын
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 ✌
@usamafiaz69643 жыл бұрын
Love You Bruh. I'm in 3rd semester and studying Data Structures. Its Going Outstanding.
@SimpleSnippets3 жыл бұрын
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 😇
@minahilxbts59253 жыл бұрын
foundation uni?
@KingKhan-lt4mn3 жыл бұрын
@@minahilxbts5925 may be fast uni faisalabad campus
@abdulwahabkhan52602 жыл бұрын
@@KingKhan-lt4mn not fast because we have 6 digits after the branch character, just like mine
@omkarhiwant515710 ай бұрын
Same to you
@AnoopKumar-bk2us5 жыл бұрын
Today my search ends here about QUEUE... best explanation... !!! thanks !!!
@SimpleSnippets5 жыл бұрын
Thanks bro 😬 I'm glad you liked it ✌️ also please do share it with your friends bro 😊
@A9Shows5 жыл бұрын
Man; this is the best explanation I have ever heard in a KZbin video
@SimpleSnippets5 жыл бұрын
Hehe thanks bro🤟 please do share the video with your friends too 😊
@A9Shows5 жыл бұрын
@@SimpleSnippets sure
@deveshparmar91863 жыл бұрын
BEST DSA course ever on youtube love the way you teach!
@samChakravartiSamrat4 жыл бұрын
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....
@SimpleSnippets4 жыл бұрын
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 🙏
@AjayKumar-ju6sl4 жыл бұрын
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.
@vijaysinghchauhan70794 жыл бұрын
Rigorous explanation. I am satisfied. Thank you, Tanmay Sakpal.
@SimpleSnippets4 жыл бұрын
So nice of you
@albertd.bangura37943 жыл бұрын
You are the best when I think of clear and excellent explanation on KZbin! Thank you for making these videos, and I will always support you by sharing your channel with my friends and mentees!
@SimpleSnippets3 жыл бұрын
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.bangura37943 жыл бұрын
@@SimpleSnippets 💖
@servantofthelord81472 жыл бұрын
Your series has been a blessing to me and my life. May God bless you.
@mananjagani28924 жыл бұрын
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.
@SimpleSnippets4 жыл бұрын
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 ✌
@ketanahuja89394 жыл бұрын
@@SimpleSnippets please make as soon as possible on stack implement using linklist
@vissamsettykalyan56953 жыл бұрын
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!
@atharvakurumbhatte34133 жыл бұрын
Hand down! This is one of the best explanation on DS
@SimpleSnippets3 жыл бұрын
Thanks bro 🤘
@ankitapareek4893 жыл бұрын
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
@SimpleSnippets3 жыл бұрын
I'm so glad! Thanks Ankita, means a lot 😇🙏
@shapind4 жыл бұрын
Simply a perfect channel for perfect programming!!! 👊 thanks alot brother❤️
@SimpleSnippets4 жыл бұрын
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 😇
@shapind4 жыл бұрын
@@SimpleSnippets sure brother! 👊
@Aishwarya__1814 Жыл бұрын
My always go to channel for my degree is justtt simple snippets alwaysss..... Thank you brother💁🏻♀️
@subhashisbhowmik73 жыл бұрын
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
@xxxbosetoxxx99083 жыл бұрын
Thanks for the display function
@arpitnamdev70312 жыл бұрын
Queue Concept and its operations are now clear,thanks Tanmay Bhai 😍👍👍🙌🙌
@sharvarijahagirdar91604 жыл бұрын
Your channel is like finding an oasis in Sahara Desert..... Thanks for the great explanation and endless effort !!!
@SimpleSnippets4 жыл бұрын
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 ✌️
@sharvarijahagirdar91604 жыл бұрын
@@SimpleSnippets I hope you too are safe and sound at home. 😇
@UEC_AbhayKumar3 жыл бұрын
Your contents are amazing💖. I'm thankful to you from my heart❤❤
@sheemasumair7423 Жыл бұрын
Way of teaching ufffff kirrakkk hai
@Ozelea2 жыл бұрын
I think this is better approach to display the queue void display(){ if(isEmpty()){ cout
@sandeepnayak63574 жыл бұрын
Bro your way of speaking and fluency in English is wonderful...👍👌👏👏
@SimpleSnippets4 жыл бұрын
Thank you so much Sandeep. This is such a great compliment. Hope the video was good and easy to understand as well ?
@sandeepnayak63574 жыл бұрын
@@SimpleSnippets the video was wonderful bro...keep making such videos help us...👍👍👌...
@be_calm23723 жыл бұрын
Following you since 20k subscribers you had ❤️
@SimpleSnippets3 жыл бұрын
Wow that's amazing to know buddy ✌️ grateful for your support always 👍
@hareshparab78082 жыл бұрын
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
@NimishRamteke3 жыл бұрын
to understand dequeue operation better use this : void dequeue(){ if(isEmpty()){ cout
@tqaquotes93793 жыл бұрын
22:10 Drawback of "queue"
@muhammaduzmankhan23033 жыл бұрын
Best DSA explanation man
@SimpleSnippets3 жыл бұрын
Glad you think so!
@yashwardhanchavan61534 жыл бұрын
Awesome!!!! Understood everything.. Thanks.
@SimpleSnippets4 жыл бұрын
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 😇
@asaadhabibkhan84203 жыл бұрын
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....
@SimpleSnippets3 жыл бұрын
Will upload soon
@aqeeltariq48853 жыл бұрын
bro you are the best
@SimpleSnippets3 жыл бұрын
Thank you so much buddy
@SGAbid2 жыл бұрын
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
@kuntalgupta74395 жыл бұрын
even if the queue is empty, the COUNT shows 1. Please correct that exception. . . Good work man!
@SimpleSnippets5 жыл бұрын
Thank you so much 😇
@akashkhairal5 жыл бұрын
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.
@shubhgupta25394 жыл бұрын
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..
@dhonddevameya23624 жыл бұрын
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.
@sulabdhungana33274 жыл бұрын
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; } }
@laxmigupta6984 жыл бұрын
Wow...now I know what is queue... 😌 Thankyou sir...🙏🙏🙏
@SimpleSnippets4 жыл бұрын
That's great to know buddy 😁 please subscribe & share this channel with your friends yaa😊✌️
@konstantinossimatos346627 күн бұрын
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
@harshpratapsingh16383 жыл бұрын
If you will take question it will be better 🙂
@AnkitKumar-xz4uh3 жыл бұрын
when we enter count in empty queue then count value should be 0 but in this code count value is showing 1
@christianclark13093 жыл бұрын
You can call isEmpty and return 0 if it is true to fix this
@AnkitKumar-xz4uh3 жыл бұрын
@@christianclark1309 thanks dude
@Nader953 жыл бұрын
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 Жыл бұрын
I was thinking the same thing but then how would the code look like? Could we use a for loop?
@dhonddevameya23624 жыл бұрын
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?
@SimpleSnippets4 жыл бұрын
You can make that happen according to your needs. Generally its not how a very basic queue operates ✌
@dhonddevameya23624 жыл бұрын
@@SimpleSnippets ok.Thanks
@akhileshdhindsa88304 жыл бұрын
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.
@SimpleSnippets4 жыл бұрын
You can add that functionality with some extra code ✌
@SudhanshuSingh-ew2fi4 жыл бұрын
Why we cannot have peek operation in queue data structure?
@SimpleSnippets4 жыл бұрын
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 ✌
@gauravbhasme14613 жыл бұрын
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
@gauravbhasme14613 жыл бұрын
but you are teaching in an awesome way I love it and now I'm addicted to learning from only you
@classim37154 жыл бұрын
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
@classim37154 жыл бұрын
My English is great but I hope you understand what i meant
@daverussell40523 жыл бұрын
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
@MithleshKumar-pr7ew3 жыл бұрын
Very very thankful sir
@pragya_mishra292 жыл бұрын
Thankyou so much....explained it so well.
@gopeshsinghal36924 жыл бұрын
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
@SimpleSnippets4 жыл бұрын
Yes agreed! This was a silly mistake from my side ✌
@nikunjsethi93512 жыл бұрын
We can just use return (rear+1); for count
@melusimoyo32492 жыл бұрын
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
@joseph20733 жыл бұрын
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 !!
@dibbyabarua94994 жыл бұрын
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
@SimpleSnippets4 жыл бұрын
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 ✌
@dibbyabarua94994 жыл бұрын
@@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?
@MasterPanda109983 жыл бұрын
@@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
@dibbyabarua94993 жыл бұрын
@@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.
@vikasbisht8914 жыл бұрын
in dequeue why we have written return x, i mean we dont need that x right. could the return type of dequeue be void??
@SimpleSnippets4 жыл бұрын
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 😇
@khyatiyadav28734 жыл бұрын
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
@SimpleSnippets4 жыл бұрын
I have done stack using linked list and queue using linked list I guess. check the full course!
@khyatiyadav28734 жыл бұрын
Ok thankyou Then please make a vedio on Dqueue
@anishamundra6014 жыл бұрын
Amazing explanation
@SimpleSnippets4 жыл бұрын
Thank you Anisha, please do subscribe & share the videos with your friends. Thats the biggest support you can provide to the channel 😇
@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.
@aizazalikhan77044 жыл бұрын
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-gd3tn4 жыл бұрын
to overcome this limitation, circular queue comes into picture
@aroobamalik90674 ай бұрын
nope in display i should be less then rear else it will display zeros void display() { if (isempty()) { cout
@nitismita10352 жыл бұрын
Thank bro 🙏🙌love 💘
@nafisahmed36072 жыл бұрын
Amazing ❤️🇧🇩
@mahesh-jg3zx4 жыл бұрын
Sir please 🙏🙏 🙏 do the video on queue abstract Data type
@rahmadinijihan1103 Жыл бұрын
thanks so much man
@mdsisakib58972 жыл бұрын
Count method has a bug. The first statement must be: if(isempty()) return 0;
@engineersanaullahvlogs3 жыл бұрын
best explanation sir you are the best i realy like it good sir keep it up you deserve the suscess insallah
@SimpleSnippets3 жыл бұрын
Many many thanks
@engineersanaullahvlogs3 жыл бұрын
@@SimpleSnippets Most welcome sir i really liked your vedios very helpful seriously from islamabad pakistan
@snehapatil46773 жыл бұрын
Best explanation 💯💯
@SimpleSnippets3 жыл бұрын
Appreciate that! Please do share the videos and our channel with your friends if you want to genuinely support me & our channel!✌😇
@muhammadatif76024 жыл бұрын
You are awesome😇
@SimpleSnippets4 жыл бұрын
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 ✌
@mdikbalhosen17113 жыл бұрын
your tutorial is awesome. It will be more effective if you give the source code.
@Zeeshanhaider-wo5bs8 ай бұрын
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?
@ameerhamza11823 жыл бұрын
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???
@ahmedrizwan71554 жыл бұрын
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??
@bingkysskiliwaax79414 жыл бұрын
You re wrong
@muhammaduzmankhan23033 жыл бұрын
Amazing
@SimpleSnippets3 жыл бұрын
Thank you! Cheers!
@Mahesh-wr6uc4 жыл бұрын
Bro kindly can you please make a vedio on queue by dynamic data structures
@SimpleSnippets4 жыл бұрын
Sure thing but will take time :-)
@Mahesh-wr6uc4 жыл бұрын
@@SimpleSnippets ok bro
@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
@yogeshjangid2703 жыл бұрын
thank you! :)
@kaushik78114 жыл бұрын
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.
@arnelrevilla95392 жыл бұрын
Why does my code says i use undeclared variable x? But your code runs smoothly
@ShaikSaleem786-gv9eq5 ай бұрын
One doubt bhaiya kya hum enqueue nahi karsakthaa values koo after performing dequeue operation kyku ki waha phar zero hai naa
@adarshtripathi31993 жыл бұрын
in count function what if the queue is empty --> rear-front+1 would give wrong ans
@muhammadrafi32762 жыл бұрын
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.
@tejaskakad42294 жыл бұрын
What if you want to make a queue of size value entered by the user?
@SimpleSnippets4 жыл бұрын
dyanmic memory allocation ✌
@kshitizkaintura21172 жыл бұрын
/* int dequeue(){ if (isempty()) { cout
@duxstybrick25364 жыл бұрын
I didn't see any particular use of variable front it just use to store 0?
@algorithmo1343 жыл бұрын
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
@moralstories41883 жыл бұрын
Sir can you please upload quiz for your covered topics. Thank you
@SimpleSnippets3 жыл бұрын
As soon as possible
@pranavpatki4 жыл бұрын
can you pls explain how to enter size of array dynamically instead of already keeping it as 5??
@dt81294 жыл бұрын
int s ; int arr[s]; and then you can take value of s ; cin>>>s ;
@joanjoshy15994 жыл бұрын
@@dt8129 where should we include this code? Under private or public section?
@tiptrcks39602 жыл бұрын
@@dt8129 better way is to use a pointer : int* ptr = new int[take input from user]
@hgtd2700 Жыл бұрын
i went to the site for this topic and in there is an error in the dequeue implementation
@nabeehazahid96134 жыл бұрын
bu the display function, the address of the elements is also getting displayed after the elements . I am new to c++ plz help
@erehuchiha3034 жыл бұрын
What if we are having some of our array entries as zeroes.. it will just make confusion ? Any soln over it?
@shortsbytuffy_shero84303 жыл бұрын
Sir ,the only thing I didn't get is when we assign all values of array 0 .them why queue is empty??
@elmo26832 жыл бұрын
Yes Queue is filled with zeros but we have assigned front and rear as -1 therefore Queue is empty.
@elmo26832 жыл бұрын
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?🤔
@namithamadhusudan76133 жыл бұрын
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?
@fatimaiqra21693 жыл бұрын
if we initialize arr[i]=Null; in constructor ,is it correct?