only fantastic intro explanation to stacks and queues I could find on TH-cam. Thank you so much for putting the content together and doing all the work to get it here so we can enjoy.
For the Queue: You could also store the last instruction as a bool (true for remove and false for add). Then if the pointers are pointing to the same and the last instruction wad remove, it's empty and vice versa for full. Then you don't need to keep around an extra empty wasted slot in the Queue. This is slightly nicer and more efficient imo.
So, for a queue, if the queue is empty, both pointers overlap. I get it. But when it is full, you said that it is full only when back pointer is to the left of front, right? That means there is a space for another element to append, but we already declared it to be full, HOW>???
Hello and thank you for your comment! As described at 12:01, this is by design - We deliberately leave a gap in the array to distinguish between the "queue full" and "queue empty" states. You don't _have_ to do things this way, but this is the simplest.
Hello and thank you for your comment! That's certainly something you could do, and would be useful in a practical context. However, this is generally out of scope in the classic definition of a stack, which is why it is omitted here.
Hello and thank you for your comment! If you would like updates, please subscribe to the channel! You can also find playlists on my profile for videos classified by topic.
You're welcome! I have some videos on Big O Notation. Perhaps you might want to start on my series "Asymptotic Notations": th-cam.com/play/PLJse9iV6Reqh5B_w9koGyT7nlYm92iITk.html
+Boti Bot Hello and thank you very much for your comment! Happy to be of help =) Normally, if I can help it, I avoid showing pseudocode in my videos. The reason for this is because I notice that many learners focus too much on the pseudocode before getting the intuition - That's why my focus is on getting the intuition right!
your explanations are very good and easy to understand for all levels of knowledge, but more visual would really help people to stay focused. saying this because i can see this channel growing,especially with all the bootcamps students are all youtubing for clear understanding. like myself
+Dany Han Hello and thank you very much for your comments =) Generally my principle is to adopt "just enough" visuals. Unfortunately I'm a full time student doing this as a hobby on the side, so I don't really have the time to go beyond the strictly necessary.
Hey buddy. Awesome video, just wanted to ask: My OCR A level computer science, hodder education, text book states that to push data to a stack, you increment pointer then push, whereas you have said you push then increment. Is my text book incorrect, or have I understood you incorrectly? Thank you
Heya Boti Bot =) Interestingly, neither is wrong! The meaning behind the stack pointer can change, and it is the semantics that dictates the implementation. My method (push then increment) works because my stack pointer points to the _next free space_ on the stack. Hence, of course it makes sense to push to that space before I move the pointer up. Your textbook's method (increment then push) works because their stack pointer points to the _topmost item_. You don't want to replace that item on push! Instead, you want to climb up to the next free space before insertion. Of course, it's important to know that checking for stack empty and full conditions will be different also depending on the meaning of the stack pointer! I'll let you figure out where the differences are (an "exercise for the reader", so to speak), let me know if you need more hints =)
Hello and thank you very much for your comment and support! Glad you liked the video and hope to see you around in the comments section of more videos to come =)
+Andrew Gheorghiu Hello and thank you for your comment! Unfortunately I don't have a lot of experience with microcontrollers! But I'm currently seeing what I can do with my raspberry pi. If I figure something out I'll work on some vids!
+kiran kiran Hello again! The queue covered in this video is already a circular queue, so that's already available. As mentioned, efficient priority queues require a lot more background to understand, so I'll put that on the list for a later time.
+kiran kiran Hello and thank you for your comment! I'm not sure how that would fit into a video though... Different types of standard queue aren't all that varied. And looking at more complex variants like Priority Queues would require a lot of additional background, so both ways feels awkward! Do you have any idea in mind of what you would like to see in a video about types of queues?
+main_gi It's still directly left - That's the beauty of a circular buffer! To implement this on a simple flat array, we apply the "wrap around" condition, so that the element directly to the left of the first item is at the far right of the array.
Yeah, I get that wouldn't be too hard to implement, but it does seem an edge case that could be made more simple somehow instead of if f-b = 1 OR (b = len(array) AND f = 0).
+main_gi Oh, I don't think you need to check for multiple conditions like that. We can ascertain that the back pointer is "left" of the right pointer by doing: if ( (back+1)%len == front ) { // Queue is full } This works for all cases, corner or otherwise.
+main_gi Hehheh, yeah, I actually didn't realize it could be that simpler either. I teach the tutorials for an undergrad course at my uni, and when I saw that method in the answer sheets, I was like, oh, that's smart. I honestly have no clue about the performance! The modulo operator is known to be slow, so depending on the architecture, checking say, 3 or so conditions for equality might be faster than performing modulo. But this is very much micro-optimization, and I doubt the impact will be perceptible.
hey bud great channle im going to subscribe and wannted to know if you can help me out with the following ideas model and protocol stack, implementation details of various network protocols, ROUTING ALGORITHMS
+austin sandoval Hello and thank you for your comment! Unfortunately, networking has never been a particularly strong point for me, and I'm not familiar with any of the topics you've mentioned. I'll look them up, but whether or not I'll do videos on them depends on how well I can understand them!
Hello and thank you for your comment! It's unfortunate, but sometimes in university, professors have to cover a lot of the underlying theories and math, so that's why! I don't blame them, but I'm glad I could help you fill in the gaps!
An entire 60minute class wrapped up into 15min. Nice work man.
Hello and thank you very much for your comment! Glad you liked the video =)
dude, you rocked this. best tutorial on a particular subject. A+.
Hello and thank you very much for your comment! Very happy to be of help =)
You are better than the programming profs in university of waterloo, thank you!
Hello and thank you very much for your comment! Very happy to be of help =)
Haha Waterloo!! Toilet university??
great explanation man, thanks for your help!
You're welcome! Very happy to be of help =)
You are Awesome person....ThankYOU sending you lots digital kisses
only fantastic intro explanation to stacks and queues I could find on TH-cam. Thank you so much for putting the content together and doing all the work to get it here so we can enjoy.
Hello and thank you very much for your comment! Very happy to be of help, and glad you liked the video =)
I did not understand anything from my Professor, But Thanks to you , made it crystal clear.
Thank you very much! Very happy to be of help =)
Your Lecture is very good quality, informative. Thank you sir
You're welcome! Glad to be of help =)
This is unbelievably helpful. An amazing, in depth explanation of both data structures!
Hello and thank you very much for your comment! That's great to hear, very happy to be of help =)
Love this. I actually didn't know about the short cut for using the mod function.
Hello and thank you very much for your comment! Glad you liked the video =)
Great explantion man, it is clear, concise and short. Very helpful!!!!!
Hello and thank you very much for your comment! Glad to be of help =)
Hello there! i just want to say this was the most clearest explanation of stacks and queues that has been explained to me. Thank you.
Hello and thank you very much for your comment! That's really great to hear - I'm very happy to be of help =)
you're amazing . I really the love the way you explain things, you explained everything in a single video.
thank you very much .
+Yu Yureka You're welcome! Really glad you liked the video =)
it's amazing. your explaination is straightforward. cool!
Hello and thank you very much for your comment! Very happy to be of help =)
Man.... You have elaborated pretty nicely!
Hello and thank you very much for your comment! Glad you liked the video =)
For the Queue: You could also store the last instruction as a bool (true for remove and false for add). Then if the pointers are pointing to the same and the last instruction wad remove, it's empty and vice versa for full. Then you don't need to keep around an extra empty wasted slot in the Queue. This is slightly nicer and more efficient imo.
I just used add and remove instead of enqueue and dequeue because of brevity
Hello and thank you for your comment! That's a cool approach, thank you for sharing.
hey very nice video!!! i missed my classes on the topic in school and the video was a really big help!! strongly recommended!
+Samar Khan Thank you very much! Happy to be of help =)
Great video. It was long, but if you take it slow you come out with a great understanding. Thanks for the info brother :)
Hello and thank you very much for your comment! Sorry about the length - I'm glad you found it useful regardless!
still useful in 2021. thanks for the video (from the future) :3
You're welcome! Very happy to be of help =)
Lovely explanation!
Hello and thank you for your comment! Glad you liked the video =)
So, for a queue, if the queue is empty, both pointers overlap. I get it.
But when it is full, you said that it is full only when back pointer is to the left of front, right?
That means there is a space for another element to append, but we already declared it to be full, HOW>???
Hello and thank you for your comment! As described at 12:01, this is by design - We deliberately leave a gap in the array to distinguish between the "queue full" and "queue empty" states. You don't _have_ to do things this way, but this is the simplest.
Resize the stack if it is full (which only happens with arrays) - don't throw an error. Just put all of the elements into a larger array.
Hello and thank you for your comment! That's certainly something you could do, and would be useful in a practical context. However, this is generally out of scope in the classic definition of a stack, which is why it is omitted here.
sir it's very amazing i like this one lecture so much!!!!!!!!!!!!!!!!!!!!!
Thank you! Happy to be of help =)
Thanks, brother...it was a great explanation.
You're welcome! Happy to be of help :)
keep it up, your explanation really helpful.
Hello and thank you for your comment! Glad to be of help =)
Awesome! Really an informative tutorial!!
Hello and thank you very much for your comment! Very happy to be of help =)
lucid explanation, man! Thank you for this!
Thank you very much! Glad you found the video useful =)
This video is Awesome. 😇😇 Please post some more videos on Data Structures and algorithms.
Hello and thank you very much for your comment! I definitely will, more to come :)
Awesome explanation! Subscribed.
Hello and thank you very much for your comment and support! Hope to see you around on the comments of new videos to come =)
Hello sir. This video was very good and useful as well. I would like to get the updates of other videos related to data structures 😊
Hello and thank you for your comment! If you would like updates, please subscribe to the channel! You can also find playlists on my profile for videos classified by topic.
thanks for the explanation man!
You're welcome! Happy to be of help =)
This was wonderful! Thanks so much for your help :)
You're welcome! Very happy to be of help!
Thanks for this video, this is very clear !
You're welcome! Very happy to be of help =)
great explanation in very details. thanks
Could you do a BigO natation video for new beginner?
You're welcome! I have some videos on Big O Notation. Perhaps you might want to start on my series "Asymptotic Notations": th-cam.com/play/PLJse9iV6Reqh5B_w9koGyT7nlYm92iITk.html
This helped me out very much.
Thank you.
Tip for improvement, it would be awesome if you included pseudocode for both stacks and queues :D
+Boti Bot Hello and thank you very much for your comment! Happy to be of help =)
Normally, if I can help it, I avoid showing pseudocode in my videos. The reason for this is because I notice that many learners focus too much on the pseudocode before getting the intuition - That's why my focus is on getting the intuition right!
your explanations are very good and easy to understand for all levels of knowledge, but more visual would really help people to stay focused. saying this because i can see this channel growing,especially with all the bootcamps students are all youtubing for clear understanding. like myself
actually u use fair amount of visual ;)
+Dany Han Hello and thank you very much for your comments =) Generally my principle is to adopt "just enough" visuals. Unfortunately I'm a full time student doing this as a hobby on the side, so I don't really have the time to go beyond the strictly necessary.
Thank you. Good explanation.
You're welcome! Very happy to be of help =)
Hey buddy. Awesome video, just wanted to ask:
My OCR A level computer science, hodder education, text book states that to push data to a stack, you increment pointer then push, whereas you have said you push then increment. Is my text book incorrect, or have I understood you incorrectly?
Thank you
Heya Boti Bot =)
Interestingly, neither is wrong! The meaning behind the stack pointer can change, and it is the semantics that dictates the implementation.
My method (push then increment) works because my stack pointer points to the _next free space_ on the stack. Hence, of course it makes sense to push to that space before I move the pointer up. Your textbook's method (increment then push) works because their stack pointer points to the _topmost item_. You don't want to replace that item on push! Instead, you want to climb up to the next free space before insertion.
Of course, it's important to know that checking for stack empty and full conditions will be different also depending on the meaning of the stack pointer! I'll let you figure out where the differences are (an "exercise for the reader", so to speak), let me know if you need more hints =)
Really helpful,thanks dude
You're welcome! Very happy to be of help =)
thanks man u make it really easy understanding , get SUBSCRIBE YOU DESERVE IT, BEST REGARDS
Hello and thank you very much for your comment and support! Glad you liked the video and hope to see you around in the comments section of more videos to come =)
nice explanation ,great job!, can you make more videos about microcontrollers ?
+Andrew Gheorghiu Hello and thank you for your comment! Unfortunately I don't have a lot of experience with microcontrollers! But I'm currently seeing what I can do with my raspberry pi. If I figure something out I'll work on some vids!
great vid, subscribed
Thank you very much for your comment and support! Looking forward to hearing more from you In the comments section of future videos.
Great explanation thank you!
+Zacadea You're welcome! Very happy to be of help!
plz explain about circular and priority queues.....
+kiran kiran Hello again! The queue covered in this video is already a circular queue, so that's already available.
As mentioned, efficient priority queues require a lot more background to understand, so I'll put that on the list for a later time.
Thanks a lot!
You're welcome! Very happy to be of help =)
It's great!
Hello and thank you for your comment! Happy to be of help =)
please explain about types of queues
+kiran kiran Hello and thank you for your comment! I'm not sure how that would fit into a video though... Different types of standard queue aren't all that varied. And looking at more complex variants like Priority Queues would require a lot of additional background, so both ways feels awkward!
Do you have any idea in mind of what you would like to see in a video about types of queues?
Thanks. And by the way, I like your accent!
You're welcome! The accent isn't really natural, but I'm glad you like it!
Kelas Strukdat A mana suaranya!!!!
thank you very much
You're welcome! Very happy to be of help =)
Er, directly left? What if we filled the queue without a single dequeue?
+main_gi It's still directly left - That's the beauty of a circular buffer! To implement this on a simple flat array, we apply the "wrap around" condition, so that the element directly to the left of the first item is at the far right of the array.
Yeah, I get that wouldn't be too hard to implement, but it does seem an edge case that could be made more simple somehow instead of if f-b = 1 OR (b = len(array) AND f = 0).
+main_gi Oh, I don't think you need to check for multiple conditions like that. We can ascertain that the back pointer is "left" of the right pointer by doing:
if ( (back+1)%len == front ) {
// Queue is full
}
This works for all cases, corner or otherwise.
Oh, uh, crap. I guess that works too! Hm... in code complexity, how is using modulo in terms of performance versus edge cases?
+main_gi Hehheh, yeah, I actually didn't realize it could be that simpler either. I teach the tutorials for an undergrad course at my uni, and when I saw that method in the answer sheets, I was like, oh, that's smart.
I honestly have no clue about the performance! The modulo operator is known to be slow, so depending on the architecture, checking say, 3 or so conditions for equality might be faster than performing modulo. But this is very much micro-optimization, and I doubt the impact will be perceptible.
THANK YOU!
You're welcome! Glad to be of help =)
Thank you mate! (:
You're welcome! Very happy to be of help =)
What is 0612?
It comes from my birthday! I know, it's lame and but I picked it ages ago and it stuck!
Oof well explained friend, thank you
You're welcome! Very happy to be of help =)
Nice
Thank you! Glad you liked the video =)
Thanks my lil' Asian nigga
You're welcome! Very happy to be of help =)
hey bud great channle im going to subscribe and wannted to know if you can help me out with the following ideas
model and protocol stack, implementation details of various network protocols, ROUTING ALGORITHMS
+austin sandoval Hello and thank you for your comment! Unfortunately, networking has never been a particularly strong point for me, and I'm not familiar with any of the topics you've mentioned. I'll look them up, but whether or not I'll do videos on them depends on how well I can understand them!
just realized that my professor sucks LOL
Hello and thank you for your comment! It's unfortunate, but sometimes in university, professors have to cover a lot of the underlying theories and math, so that's why! I don't blame them, but I'm glad I could help you fill in the gaps!
amazing explanation thanks!!
You're welcome! Very happy to be of help :)