Understanding the Doubly Linked List

In many operations operated on a Singly Linked List, we've observed that, to get a previous node of any particular node, we need to traverse from the head of the LinkedList. This is a performance hit. Of course, we can ignore it if the LinkedList is small but, for Linked Lists that are big in size, the time taken to get the previous node is larger. To avoid this performance problem, we can simply store the previous node reference of every node in the same way we store the next node reference. This is what we call a Doubly Linked List.

We can represent it in a graphical way as follows:

Like a Singly Linked ...

Get Hands-On Data Structures and Algorithms with Kotlin now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.