You explained this better in 5 mins, than my professor could in 2 hours! Thank you so much!
@abdulmohibabdulrahman69242 жыл бұрын
Legend 🙄🙄
@argonred2 жыл бұрын
So very true
@mutatednut2 жыл бұрын
Better than my professor could in 3 weeks
@drzlilj2 жыл бұрын
Better than my professor could in 2 semesters
@tannerbarcelos68805 жыл бұрын
It is funny when you get a pretty good foundation in your intro to comp sci courses how easily it is to understand these data structures. Then again, Gayle is an amazing teacher! Not a luxury we all get with college, lol.
@tan80675 жыл бұрын
Thank you very much ma'am. Stacks and Queue's have been stressing me out for the longest, but now I have actually taken the time to sit down and understand them and they are actually fairly simple, at the mention of pointers, I used to tremble, but now I realise that I have got nothing to fear at all!
@Digger-Nick4 жыл бұрын
7 months late, but a stack and a queue are the most basic concepts to understand...
@tan80674 жыл бұрын
@@Digger-Nick I agree. On paper, they're VERY easy to understand. I just had trouble implementing them when it came to actual problems.
@hilapartuk67695 жыл бұрын
Greate video! One suggestion - When implementing a Stack, it makes more sense to call the Node's pointer "prev" than "next", because logically it doesn't point to the one that comes after him :)
@laurafigueroa99224 жыл бұрын
true, I called mine 'down' :)
@vaibhavyadav-patil36954 жыл бұрын
'down' makes much more sense.
@laurafigueroa99224 жыл бұрын
@@vaibhavyadav-patil3695 yea! Tho I was told it wasn't best practice 🤦♀️
@vaibhavyadav-patil36954 жыл бұрын
@@laurafigueroa9922 why & who told you that?
@hilapartuk67694 жыл бұрын
@@vaibhavyadav-patil3695 you're right, but Gayle used the word prev in her other videos (I think it was LinkedList, not sure)... so just to be consistent with her other tutorials :)
@najeebiBrahvi3 ай бұрын
Very Very simply explained. It is better than the Course which I bought from Apna College!
@martinmtandi3358 жыл бұрын
awesome vid. you are the first person who has really explained the coding of this algorithm in a manner i actually understood.
@dragonore20097 жыл бұрын
At the university you do as the video is depicting. At least from C++ a person can just easily use the built Queue and Stack library, but you learn nothing. At the university they show you how a Stack and Queue work, like the video and then you implement it. You are not allowed to use any STL libraries. I learned alot, when I was restricted from using STLs and I would recommend everyone make a program that can easily be done with STL libraries, but to not use them, this forces you to understand programming better.
@dragonore20097 жыл бұрын
Obviously I don't mean production code, but for someone who is learning.
@johnsena00076 жыл бұрын
You're really have a point!
@geekyprogrammer48316 жыл бұрын
@@dragonore2009 you are right!
@vela74475 жыл бұрын
Huh, at my uni we used nodes for linked lists and trees, but python lists for stacks/queues... This was a far better explanation.
@xynyde04 жыл бұрын
@@vela7447 python lists implementations are similar to dynamic array implimentations. Where as in this video stacks and queues are the implementations of linked lists.
@CSEconceptswithParinita5 жыл бұрын
Thank you so much ma'am! You're an inspiration for new tutors like me🙏💙💙💙
@silvershocknicktail66387 жыл бұрын
I see so many tutorials for coding using this same doodling/animation software, but I don't recognise it. What is it?
@procrastinator03574 жыл бұрын
Although I understand what stack is and how to implement, I’m struggling to see when I can use stack, like in which “actual programming” situations.
@kulsumkhansla41014 жыл бұрын
I think we can use in when we want to check some kind of grammar or syntax, usually in the case of a compiler( lexer and parser)
@amadmlinka48124 жыл бұрын
It is also useful for implementing a post-fix notation system, if you want some user inputed data to be calculated.
@fahimhassan90244 жыл бұрын
This is my question too lol. I understand the implementation I guess, but I have no idea where this might be required :3
@Digger-Nick4 жыл бұрын
@@fahimhassan9024 It's not as important or difficult as these people make it out to be.
@Edsiaren4 жыл бұрын
I had to use it on a calculator app that converted infix (1+2*3) to postfix(2 3 * 1 +) before calculating the problem. Converting to postfix helped a lot with nested problems (i.e. 1+2(3*4(1(3-2)))-4*3(1)) for me. I'm sure there's a work around without having to convert it to postfix, but finding a way to dig inside that parentheses and making sure those problems are solved in order was pretty troublesome. Look up postfix conversion or "Reverse Polish Notation" (RPN) on youtube, one of the videos show how a stack is used to determine what problems are going to get solved first.
@frankchen30213 жыл бұрын
Your videos are always so straight-foward!
@YoniFraimorice8 жыл бұрын
Node class in 4:20 has a private constructor ,why's that? the class Node is private, that's fine since we're only using it and exposing it to our solution class, however creating the c'tor of the Node class as private won't allow us to instantiate it (only from within the Node class)
@martinmtandi3358 жыл бұрын
got the same qstn too
@pascal38897 жыл бұрын
The outer class can access the private methods and fields of the inner class.
@gurukarthi7 жыл бұрын
Since, We are supposed to create object for the class Stack/Queue not for the class Node. Because the class Stack/Queue will take care of creating the object for the class Node. Moreover, The class Node is created to make use of data organization inside the Stack/Queue not from outside!..peace!
@mohdbilal65612 жыл бұрын
very well understood.Thanks mam from India 🇮🇳
@luiscarlosquesadasequeira15483 жыл бұрын
Can anyone explain at 3:33, in the remove method, why the tail need to be set to null after updating/removing the head? L36.
@CaveDave4 жыл бұрын
This is very confusing, it would have been much more simple to follow along if you would have kept your "line of people" analogy from the beginning 1:00 where the "tail" is on the left side making more sense because new people (nodes) will enqueue on the left side to represent an growing queue. Now you have mixed it all up: 2:40 . You add a new node but put it on the right side and make it part of the tail.
@rumelia7 жыл бұрын
This series of Data Structures is great! Succinct, clear, and to the point. I only wished they used C++ since I got a final of it coming up :D
@englotv6 жыл бұрын
this is true coding. you helped me understanding sta cks
@danielabengona51424 жыл бұрын
Where do you think it would be applicable to use them in some certain programs?
@kataya50055 жыл бұрын
does it make sense that node is a static class, since we're making instances of the node with different data ?
@mohamedalifrani54165 жыл бұрын
Interesting implementation. But "top-level static classes" don't exist in Java! So the Queue class must just be a public class. In other cases if you need a "top-level static class" you can declare it as "public final", make its constructor "private" and its members as "static".
@somerandomguy0003 жыл бұрын
that happens when you’re just reading your teleprompter without actually knowing the thing
@deli57773 жыл бұрын
Thanks for this, you made the code seem so much simpler
@theSeniorSDE3 жыл бұрын
Thanks for these easy videos to undertand.
@Eric-xh9ee2 жыл бұрын
This is by far the best explanation I've seen! PS why didn't you delete the node you popped, in the stack? I thought you always delete nodes you add otherwise you'll run out of memory
@DopetheKid2 жыл бұрын
because technically it is deleted. nothing is pointing to it anymore so its garbage collected.. when using an array, that is when you should delete because array takes up a block of memory at a time.
@凛-r3h4 жыл бұрын
Stacks and queue are pretty easy to remember their meaning. Its the same as the english meaning of stacking and queue!
@robertbonham66214 жыл бұрын
Currently working on a class project where we can choose to either do stack or queue, which one would be better implement/ use. Stacks or Queues?
@ngndnd Жыл бұрын
for the pop method in stack, it is removing the element that i added first, not the one that i added last. Or maybe im just getting confused bc of the way its actually implemented in code, idk
@hasansakib35027 жыл бұрын
Sometimes i wonder how many subscribers did you get after these wonderful lectures??
@loummad95522 жыл бұрын
I dont understand this line plz (@3:37) if head == null ===> tail == null;
@denver8324 жыл бұрын
Is 2:33 's code executable i think its not.
@joyalmeida65656 жыл бұрын
can you suggest me a title for a project which uses data structure in c. I need a project which uses link list/ stack / queues
@piero96657 жыл бұрын
Good explanation!!! thanks Gayle
@dennisrufi1436 жыл бұрын
Hello, Very well explained but I am confused with remove method. How is it actually removing a particular node in Queue?
@sonnix316 жыл бұрын
Lol, well explained, but you are confused? Watch Durga Sir and you'll understand.
@growingprogrammer65935 жыл бұрын
She actually just removes any reference to it. This means that the Garbage Collector, speaking in terms of JavaEnv, will delete it because it is a data without references.
@xynyde02 жыл бұрын
in garbage collected languages like java and python, when an object has no references or is 'unreachable', it is deleted by the garbage collector. But if you are writing the same data structures in languages like C++, you will have to manage memory by yourself. Which means, you will allocate and deallocate memory for any objects you create.
@jamesyoo675 жыл бұрын
Question for Stack.Pop(). Why do we not destroy the old Top object and set it to null, after setting the new Top?
@jamesyoo675 жыл бұрын
Edit: looking at StackOverflow, in Java and C# it is worth it to null out the reference after popping it.
@BrandonAB4 жыл бұрын
When the camp counselor tells everyone to line up at the flag pole and then when everyone does, he says to turn around, that’s LCFS.
@shibinfrancis98266 жыл бұрын
How did you add first tail? If(head == null){ head = node; tail ?}
@anjani0agrawal5 жыл бұрын
For Queue, add. If head is null shouldn't head and tail both be assigned to Node?
@DONofC0D5 жыл бұрын
That is what she's done there. In the add method she will always set the tail to the node. And if head is null, she has also set head to the node. This means head and tail points to the same node
@feifeiliu2762 жыл бұрын
Thanks! So easy to understand.
@sakshamp44883 жыл бұрын
Nice explanation. 🤩
@Kuriocity6 жыл бұрын
*I dont understand the tail node object why you are overwriting it in the add method???*
@pablocs126 жыл бұрын
Is not overwriting it, at that point of the code (line 24) the "tail" object is still an instance of to the penultimate node (the 3th in the graph), what is doing there is switching the reference of its next node to the new tail. So the "next" node of 3th one ,is now the 4th node. I hope I've made myself understood.
@abtest50532 жыл бұрын
Is it necessary to put Node class inside stack class?
@uyarahmet4 жыл бұрын
Sound of the keys, OMG :D
@sundarb66735 жыл бұрын
Thank you, Gayle!
@DopetheKid2 жыл бұрын
i dont really understand the if(head == null){ tail == null; } line in remove() of the queue. can someone explain?
@mustafak95657 жыл бұрын
in the add method of quene, cant we just let tail.next= node without the if(tail!=null) check?
@scpancakes7 жыл бұрын
It really depends on your compiler and a number of other factors, but when you try to access data members from a null pointer you will experience "undefined" behavior. In other words, you may be trying to access data from an object that does not exist! In my case it always ends in a segmentation fault. It's always best to avoid code that results in unexpected behavior. Note: coming from c++ but I imagine its much the same
@XxGummib3arxX7 жыл бұрын
Yes, you can do something like this public void add(char c) { if (head==null) { Node newNode=new Node(c); head=newNode; tail=newNode; } else { Node newNode=new Node(c); tail.next=newNode; tail=newNode; } }
@abdulrashid10605 жыл бұрын
At 3:17 you said "Remove from head of linked list" :)
@thewatcherlollol4 жыл бұрын
Well, most of these Data Structures are implemented using Linked Lists.
@baljeetsingh58135 жыл бұрын
which ide you were using?
@danielabengona51424 жыл бұрын
Why do you think it is appropriate in some certain programs?
@aishikbhattacharya42963 жыл бұрын
Why cant we use a different class for Node as we did for linkedlist
@Beziu16 жыл бұрын
why remove method returns data instead of void ?
@Lea7herFace6 жыл бұрын
it should be called dequeue
@TheMediocreDev6 жыл бұрын
It's actually changing the data (setting the tail to null) instead of just manipulating the pointers. Basically, need to return method with .data but not just .next()
@_danzo76 жыл бұрын
because its have to return the value that had been removed like when u r in a real queue and u r an integer when its ur turn they cant just say next and ignore u
@mukulsaini16593 жыл бұрын
what would be the time complexity of this?
@williamplay10006 жыл бұрын
Why are the nodes static?
@kyy61506 жыл бұрын
why do you need "Next" and "Tail" reference variables, why cant you just use "Next" as the tail instead of having 2 reference variable referring to the same object.
@MinecraftLetstime6 жыл бұрын
Then you have to traverse the queue to insert an element to the tail.
@growingprogrammer65935 жыл бұрын
This way you can avoid going through the queue to insert an element (because you already have the tail!)
@hmak54235 жыл бұрын
Amazing. Just amazing. Btw, I clicked because I thought Charlize Theron is the teacher.
@cenkercanbulut30696 жыл бұрын
Well explained, Subbed!.
@moviefanie4 жыл бұрын
Nothing wrong with this video. I found in some interviews, for Queue people especially look for enqueue and dequeue methods instead of remove and add.
@thadtayo7 жыл бұрын
Why does she create a Stack class and Queue class? Are these data structures not built into Java?
@revdevstudios7 жыл бұрын
they are but she teaches you the implementation and how these data structures work.
@XxGummib3arxX7 жыл бұрын
They are are in the Java api, but the point of the video is to show you how they could possibly be implemented and how it works internally. In her case using a linked list. What if you went to a job interview and they asked you to implement a queue? You would probably fail in that case.
@joecamroberon93225 жыл бұрын
Because the video would be 30 seconds long is she did that.
@7369398 жыл бұрын
I though that it's null when head==tail on 2:13
@zentes088 жыл бұрын
Not necessary. If we have 1 element in the queue, head==tail is true.
@yoitslemonboy69885 жыл бұрын
can we please get the source?
@syedmuqeet5 жыл бұрын
I got confused with stack push pop operation
@mergatafa85017 жыл бұрын
excellent lecture
@shoban20907 жыл бұрын
Why do we keep 'Node' as a inner class?
@officialsterlingarcher5 жыл бұрын
so that it can't be accessed outside of the queue or stack class. It doesn't make much sense on why we don't want to access it outside of this class in this scenario. But say that you're building an algorithms library for other programmers to use and you add these data structures to it. You don't want those other programmers to accidentally access the node class and start messing around with raw data without having to go through the helper functions in the outer class. That would defeat the whole purpose of the data structure you're making.
@jamesyoo675 жыл бұрын
@@officialsterlingarcher In her sample code, I can't manipulate her Stack's data because A) Top is a private member of Stack, and B) data is a private member of Node, both with no public setters or getters. Defining a private Node class within a Queue class means, outside the Queue class, I cannot freely create and use Node objects on my own.
@ms.r16113 жыл бұрын
Wow I didn't know the face behind the book: Cracking the coding interview.
@greerhanshaw8 жыл бұрын
At the risk of being tedious, can someone explain: is a stack/queue a data structure (as described here), an abstract data type (as described on Wikipedia) or both?
@GuardianTam7 жыл бұрын
It's both. it's an abstract data type when you're talking about how it behaves. it becomes a data structure when you actually implement it, since there are many different ways to do so.
@jacksonjoestar50357 жыл бұрын
A stack can be an abstract data structure, remember that an abstract data structure is A class where not all methods are initialized.
@nafeesahmed49427 жыл бұрын
How i can use this editor for practice ?
@anjaligoyal17547 жыл бұрын
hackerrank.com
@victor3btn5982 жыл бұрын
Why is stack like a linked list
@hao58685 жыл бұрын
Which IDE was used in this tutorial? Thanks!
@growingprogrammer65935 жыл бұрын
It is the default code section used in HackerRank
@Ibrah_id6 жыл бұрын
Very clear and informative ❤️
@jamesperez69648 жыл бұрын
What is the deal of the dot operator being used with the 'this' pointer? this.data = data; instead of, this->data = data; ???
@HafisCZ8 жыл бұрын
Because it's Java, not C++. In Java operator - > is for lambda. In C++ 'a.x' returns member x of the object a, and 'a->x' is short for (*a) .b (returning member of object's pointer). It's explained there better: stackoverflow.com/questions/4984600/when-do-i-use-a-dot-arrow-or-double-colon-to-refer-to-members-of-a-class-in-c
@averagehooligan6202 жыл бұрын
So helpful! thx
@NinjaTuna94 жыл бұрын
A stack is just a singly-linked list??? WTFFFF
@jx_cob59884 жыл бұрын
True, it really just defines how items are removed and added to it. There is some other stuff if you go deeper however.
@danielbreen39456 жыл бұрын
_intentionally keeps her own book at the bottom of her "stack" to show humility_
@M4th3u54ndr4d34 жыл бұрын
@@charlesj9106 lol
@Jemmeh6 жыл бұрын
Thank you for the video. I suggest using a pop filter with the microphone next time though, there's a lot of little pops in the audio and it's distracting.
@MosesHashim35 жыл бұрын
the idea of stack and queue is simple, but everyone has a different way to code it. I could not follow you and read what you were coding.
@Tux0xFF4 жыл бұрын
a static class that contains another inner class, i need to re learn java
@whitebird3655 жыл бұрын
Thank you!
@jl-dq5ch5 жыл бұрын
waiting an hour or two for a movie?!
@collegestudent60714 жыл бұрын
Why don't these tutorials specify the language...
@charleskenney35747 жыл бұрын
Wow thats good schema
@benzeltser98514 жыл бұрын
why did it take my teacher 3 hours to teach at, and not as good as this video tbh.
@tedyhy246 жыл бұрын
It's great!
@AshokAshok-ig9jk5 жыл бұрын
Super
@brd87644 жыл бұрын
FILO and LIFO.
@skylarkim226 жыл бұрын
thanks!
@0xssff3 жыл бұрын
but why Java (eww) tho?
@fatimaaw Жыл бұрын
thank u!
@RogerKeulen8 жыл бұрын
Wrong, Fake news: The _head_ is the first element. The rest is the _tail_. ;-)
@adamsadam3668 жыл бұрын
nice! =)
@duncanphillipgreen6 жыл бұрын
Hm, I don't think this will even compile!
@KwabenaAning6 жыл бұрын
Yeah...
@rasam.priyan2 жыл бұрын
I feel sad ... Just because she used Java to teach stacks and queues...
@sim1manson13 жыл бұрын
FAKE QUEUES!!!
@fernandoluis536 жыл бұрын
You did not talk about big-o at all. very unprofessional
@KelleyKouture5 жыл бұрын
she has a whole video on big-o. This video was about stacks/queues and it was very well done