 What's up, guys? My name is Michael and welcome to my YouTube channel. Today we are going to go over how to insert a node at the tail of a linkless. So basically in order to insert your node at the tail of the linkless, all you have to do is just create your new node that you want to insert it to. And then you have to traverse all the way to the end of the linkless and then just insert it there. So first, let's actually create a new node that we want to insert it to. So here we have a linkless node. Let's call it, I don't know, to insert. Let's make it a pointer. Let's get a new single linkless node. And then we're going to call it, say, data. And the next one, we're going to set it to null pointer. I believe there's, is there no constructor? There's no constructor here? That's so weird. Okay. So weird that there's no constructor. Okay. Since there's no constructor, we're going to just do to insert and set the data to be each of the individual data. To insert state is going to equal data to inserts next going to be point to know. So this is just creating the new node that we want to insert. So let's actually instead of to insert, let's call new node. Yeah. So this is creating new node is data is going to point it to the data that we just passed in, you know, it's next going to point to now because that means we're at the end. Right? Now what we're going to do is we're going to use a while loop. We actually need to set a pointer called current. And I'm going to set this equal to the head. Whoops. And then while his currents next is not equal to null. And as we didn't reach while the next element is not equal to null. That means we didn't reach the end of the link list. So what we're going to do is we're going to set current is going to equal to current next. All right, now that we did reach the land of the link list, all we have to do is just set currents next. It's going to point to our new node. And by the beam by the boom, this should work. What do they want us to do after that? Return the original node? Oh, okay. Now we're just going to return head. Okay. The other this should work. Okay, we are failing something. What are we failing? Oh, three to six seven four. Really, it's not adding 141 302 164. All right, let's expect it output. What is our output? No response on STD out. Are we supposed to print it? But let's see. I think this is not after insane 141 141 302 null. Yeah, that should, it should, should, it should work. What's the problem? Let's see new node, new nodes that equal to data, new node is next to a little pointer, while currents next is not equal to no pointer. Ideally, this should work current current data next should point to new node. This should work. Let's see what are we doing wrong? It's probably just syntax. Probably I think it's a little bit syntax. All right. Next points in all pointer. Why is it hidden test case? Expected output should be 141 302 164 53. Current is going to equal to head. Currents next is not equal to a pointer, current is the current dot next current the next point to new node, we're done with return head. What's the problem? Point to head is not equal to next. This should be a copy. Um, should be double pointer. I don't think so. Let's look at the discussion. I forgot the first part. If that is equal to null, head point to new node, return head, grant you that head point to new node, return head, magic work, still not working. Why? Seq fault, runtime error, that is equal to no pointer. And we're going to set it to the new node. And we're going to return head should work. Let's see. Oh, I missed it. Yeah, that's what I was doing. Point to head. Go to the next. No return head. Yeah, that's literally what I was doing. This challenge does not work anymore. What the hell? Let's let's look up C plus plus. Read the main function before attempting. Okay, this was literally what I was doing. Opposition that return head. Yeah, I was literally doing this. I didn't use a new. Is that the reason why they should just have like a constructor? Yeah, okay, that was really stupid. But yeah, basically, you need to create a if you're gonna do this, you need to use a new single link close to new. So yeah, create your new node. If it's, then you have to set the data to be the data passed in, then you set your new nodes next to be null because that means you're at the end of the list. If our current head is equal to null, we just set our head to equal to the new node that we're passed in. And we just return head. Otherwise, let's, we're gonna keep going until we reach the end of the link list, which is check this by currents next, not equal to no pointer, we keep going next. And then after that, we just set our the last elements next is going to equal to our new node that we passed in. And we return the head of it. So yeah, that's basically just this code. We're just gonna keep going next until you reach the end. And yeah, then once you reach the end, you just point it to the new node that you're inserting it. And then we return the head. So yeah, hope you guys enjoyed this video, write com subscribe, I'll check guys later peace.