Python Linked list implementation I - insert
In this video, I will start the linked list implementation from scratch.
So, first of all, let's create a distinct class for the nodes in the linked list. It's going to have the class Node with read object. This is how we create a class in Python, and we are going to have a constructor, so we define the init method. Basically, this is how we represent the constructor in python with the self and the data, whenever we instantiate a node we are going to specify the data we would like to store in this node. Every node is going to store the data itself and going to store a reference to the next node.
Then we have the linked list class with the object. We have the init constructor with the self, and basically, we are going to create the head of the linked list.
That's all about the head and the size and we are going to have a method, for example, insert start is going to insert some data at the beginning of the list. So, first of all, we have to increment the size so self.size plus 1. We just increment the size, and then we have to instantiate, and newNode it's going to be a node with the data. This is how we instantiate a class in Python.
Thanks for watching!
Sur cette page du site, vous pouvez voir la vidéo en ligne Python Linked list implementation I - insert durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur TheMomentZone 17 octobre 2019, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 2,053 fois et il a aimé 0 téléspectateurs. Bon visionnage!