Python Linked list implementation I - insert

Veröffentlicht am: 17 Oktober 2019
auf dem Kanal: TheMomentZone
2,053
0

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!


Auf dieser Seite können Sie das Online-Video Python Linked list implementation I - insert mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer TheMomentZone 17 Oktober 2019 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 2,053 Mal angesehen und es wurde von 0 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!