Open In App

Is two way linked list and doubly linked list same?

Yes, a two-way linked list and a doubly linked list are the same. Both terms refer to a type of linked list where each node contains a reference to the next node as well as the previous node in the sequence.

The term “two-way” emphasizes the ability to move in both directions through the list, while “doubly” highlights that there are two links per item. Despite the different names, they refer to the same structure.



Doubly Linked List

What is a Two-Way or Doubly Linked List?

A two-way or doubly linked list is a more complex type of linked list which contains a pointer to the next as well as the previous node in the sequence. This allows for more flexibility and operations than a simple linked list.

In a doubly linked list, each element has three parts:



This setup allows you to move forward to the next item or backward to the previous one, which is why it’s called “two-way” or “doubly” linked.

Why Use a Two-Way or Doubly Linked List?

A doubly linked list allows for traversal in both directions, forward and backward. This is useful in applications where you need to navigate back and forth such as in a web browser’s history. In a doubly linked list, insertions and deletions at both ends (front and back) are efficient. They can be done in constant time O(1).

Advantages of Two-Way or Doubly Linked List Over Other Data Structures:

Doubly linked lists have several advantages over other linear data structures.

Real-World Applications of Two-Way or Doubly Linked List:

Doubly linked lists are used in various real-world applications:

Conclusion

A two-way linked list and a doubly linked list are the same thing. They’re just two names for a data structure that lets you move forwards and backwards through your elements, giving you more flexibility in how you navigate your data.

Article Tags :
DSA