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: Swift
Lesson 1 of 1
  1. 1
    Let’s implement a linked list in Swift. As you might recall, a linked list is a sequential chain of nodes. Remember that a node contains data and a link to the next node. We are going to use the…
  2. 2
    We now have a linked list class! But any linked list we create is empty and stays that way, which isn’t very useful. In this exercise, we’ll give LinkedList instances the ability to add nodes by …
  3. 3
    Currently, we don’t have an easy way of printing a linked list in a format that tells us about the nodes or data stored in them. For example, printing the linked list that stores the plants in a …
  4. 4
    Let’s add some more functionality to our LinkedList class. If we can retrieve all the nodes from a linked list, we should also be able to access a specific node depending on its position. Just li…
  5. 5
    Let’s work on the last requirement for our LinkedList class, the ability to remove a node from a linked list. If we can find a node in a linked list, we can remove it by updating the references be…

How you'll master it

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

Pro Logo