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!
In questa pagina del sito puoi guardare il video online Python Linked list implementation I - insert della durata di ore minuti seconda in buona qualità , che l'utente ha caricato TheMomentZone 17 ottobre 2019, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 2,053 volte e gli è piaciuto 0 spettatori. Buona visione!