Key Concepts

Review core concepts you need to learn to master this subject

Removing a node from the middle of a linked list

When removing a node from the middle of a linked list, it is necessary to adjust the link on the previous node so that it points to the following node. In the given illustration, the node a1 must point to the node a3 if the node a2 is removed from the linked list.

Linked Lists: Python
Lesson 1 of 1
  1. 1
    Let’s implement a linked list in Python. As you might recall, each linked list is a sequential chain of nodes. So before we start building out the LinkedList itself, we want to build up a Node clas…
  2. 2
    With the Node in hand, we can start building the actual linked list. Depending on the end-use of the linked list, a variety of methods can be defined. For our use, we want to be able to: - get the…
  3. 3
    So far we can: - create a new LinkedList using .init() - get the head node of the list using .get_head_node() Next up, we’ll define methods for our LinkedList class that allow us to: - insert…
  4. 4
    Nice! Now we have a bunch of helpful LinkedList methods under our belt. The final use case we mentioned was the ability to remove an arbitrary node with a particular value. This is slightly more …
  5. 5
    Congratulations, you have implemented a linked list in Python! We did this by: - Defining a Node class to hold the values and links between nodes - Implementing a LinkedList class to handle extern…

How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory

Pro Logo