 Now so far if we've wanted to store something into a list we've talked about queues and we've created stacks and whatnot But the kind of interesting thing is we've looked at it in this approach Sort of storing everything inside of an array. All right. Well What if I don't have an array or maybe in this case? I wanted to add another Element to my stack or my queue. I've only got three slots in my array And so before I even get to make my stack say for example I wanted to add four I would have to come in and make a new Array copy all those elements over and then I got to add it or I maybe double the size double the capacity of the stack So this becomes an issue as we add elements in because as you can see it becomes a sort of a problem of Constantly building our our array. What we do is we we actually classify this as memory contiguous implementations that P is terrible Implementation The entire idea is if we think about an array once again, it's this stick of memory and Every element just happens to naturally fall in line so one's there two's there three's there four's there and They all operate off of some index that just points to them Where in the the variable of that array we store The issue is as I keep on kind of pointing out is as I want to add more elements That means that has to constantly get bigger. I have to constantly copy over my elements into new arrays and replace arrays and it can just become a Very intense memory intensive So one of the things we can do is instead of looking at a memory contiguous implementation we can create something we would call a linked memory memory Implementation and this is oftentimes where you start to see the introduction of what we call a linked list The idea here is if this is being stored in an array What if I took that array concept and threw it out the window just like with recursion I took the idea of a loop and I threw it out the window Well in this case, I would have some let's just call it a list for right now some Data type that's a list and it stores elements inside of it One of the things that it's going to have in it is something we would classify as my head. What is the? top of the list as We can kind of imagine that changes depending on if we're looking at a queue a stack or any of the other data types That we'll start to get into Now the same kind of concept is going to come into play that we saw with an array as I put elements into Instead of my array into my list We won't call them elements because that's actually only just a small portion of Everything in there right we're going to use a new generic term considered a node Now the idea behind this node is there's a lot more going on Let's again think about our array for a second if I wanted to sort of know the start Let's say that's the variable name. I would come in And I just magically was able to do a zero because I know that's the start because it's the first thing in the elements I Don't have that index. I don't know What the start is, you know again? That's where head is that's actually what head is kind of doing for us But the same approach in array in my array variable What's next? Oh, well, I just happen to increase my index And all right well That's nice, but the big thing I wanted to focus in on is that word I used I said what's Next and that's where sort of nodes start to kind of differ a little bit Let's say for example, I created a node one and I added it to my list for our sake We'll worry about kind of that implementation a little later But if I added in that node one we oftentimes see it implemented in some Former fashion like this Kind of two squares sandwiched together and in that first left column. This is where we would classify We store the element again because it could be a string It could be a char it could be any data type that we wanted to be over here though This is where we would ask that next question This would we actually create as a variable of the node class that we've implemented The idea here is I could come in anywhere and point to whatever my next element is Since this is the only element say in my list It would point to no that just means that I'm at the end of my list But what if I then in turn came I'll keep that that arrow there I Came in and I created a new node this time just to kind of mirror what I've got going on here We said node 2 Well since I made one node this way I can make a second of this way. That's still my element and this Now has its own next and since there's nothing after this I Can give it the null Same kind of approach comes into play as we then in turn make I'll stop at node 3 I Come in I create it boom boom boom