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!
En esta página del sitio puede ver el video en línea Python Linked list implementation I - insert de Duración hora minuto segunda en buena calidad , que subió el usuario TheMomentZone 17 octubre 2019, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 2,053 veces y le gustó 0 a los espectadores. Disfruta viendo!