Implementing Linked List Operations in Python
In this article, I’ll be walking you through some implementations of linked list operations in python so let’s get our hands dirty a little bit.
As a quick reminder, some of the basic operations in python linked list that we’d be looking at are
* Creating a node
* Creating a linked list
* Inserting a node at the beginning of a linked list
* Inserting a node at the end of a linked list
* Inserting a node in between linked list
* Traversing a linked list
* Removing a node
* Updating node value
Creating a Node
The code above shows how to create a node in python. There are two files, createNode.py
where the Node
class is created and the __init__
constructor is defined. The __init__
method is a parameterized constructor that takes three parameters, the instance self
being created, the node value
, and the link next_node
that takes a default value None
. The get_value()
method when invoked returns the value of the node and the get_next_node()
method when called returns the link.
In main.py
an instance of the class…