What is Two Way Header Linked List? Last Updated : 01 Apr, 2024 Comments Improve Suggest changes Like Article Like Report Two-Way Header Linked List, also known as a doubly linked list with a header node, is a type of linked list that contains a special node at the beginning called the header node. This node does not contain any data but serves as a permanent head of the list. The rest of the list consists of nodes that each contain data and two links pointing to the previous and next nodes. What is Two-Way Header Linked List?Two-way header linked list is a type of linked list which has a header node at the beginning of the linked list which does not store any data and simply points to the first node of the linked list. All the other nodes have three parts: data, pointer to the previous node and pointer to the next node. Unlike Singly Linked List where each node has one pointer, there are two pointers in each node of Two-Way Header Linked List. The previous pointer of the first node and next pointer of the last node points to NULL. Structure of a Two-Way Header Linked List:A two-way header Linked List, like any other Linked List, consists of a series of nodes. Each node contains a data field and two pointers, one pointing to the next node and one pointing to the previous node. However, in a two-way header Linked List, there is an additional node at the beginning of the list, known as the header node. This node does not contain any meaningful data but serves as a marker for the start of the list. Advantages of Two-Way Header Linked List:A Two-Way Header Linked List can be traversed in both forward and backward directions. The delete operation in Two-Way Header Linked List is more efficient if a pointer to the node to be deleted is given. We can quickly insert a new node before a given node. In a singly linked list, to delete a node, a pointer to the previous node is needed. To get this previous node, sometimes the list is traversed. In Two-Way Header Linked List, we can get the previous node using the previous pointer. Disadvantages of Two-Way Header Linked List:Every node of Two-Way Header Linked List requires extra space for a previous pointer. It is possible to implement Two-Way Header Linked List with a single pointer though (See this and this). All operations require an extra pointer previous to be maintained. For example, in insertion, we need to modify previous pointers together with the next pointers. For example in the following functions for insertions at different positions, we need 1 or 2 extra steps to set the previous pointer.Applications of Two-Way Header Linked List:It is used by web browsers for backward and forward navigation of web pages LRU ( Least Recently Used ) / MRU ( Most Recently Used ) Cache are constructed using Doubly Linked Lists. Used by various applications to maintain undo and redo functionalities. Conclusion:In conclusion, a two-way header Linked List is a specific type of Linked List that includes a header node at the beginning. This header node, while not holding any meaningful data, plays a crucial role in simplifying operations on the list and improving code consistency and readability. Whether you’re implementing a complex algorithm or simply storing data for easy access, understanding the concept and benefits of a two-way header LinkedList can be very beneficial. Comment More infoAdvertise with us Next Article What is Two Way Header Linked List? S singhdivya5 Follow Improve Article Tags : DSA Data Structures and Algorithms-QnA Similar Reads Header Linked List A header linked list is a special type of linked list which consists of a header node in the beginning of the list. The header node can store meta data about the linked list. This type of list is useful when information other than that found in each node is needed. For example, suppose there is an a 11 min read What are real life examples of Double Linked List? A real-life example of a doubly linked list is a web browser where each website you visit (node) can be navigated forward or backward to using the browserâs forward and back buttons. This allows for easy movement in both directions, similar to traversing a doubly linked list in a computer program. O 3 min read How to Create a Linked List in Ruby? A linked list is a form of linear data structure whereby the elements are not positioned closely together in memory. Each element here instead points to the subsequent one, thus leading to a chain-like arrangement. Creating a linked list in Ruby entails defining an information structure where each n 5 min read 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 3 min read Why do we need circular linked lists? Circular linked lists are particularly useful in applications where we need to cycle through data repeatedly. They are efficient for certain types of problems and can be used in various applications such as implementation of a queue, music or media player, hash table implementation, memory allocatio 3 min read Next greater element in the Linked List Given a linked list L of integers, the task is to return a linked list of integers such that it contains next greater element for each element in the given linked list. If there doesn't any greater element for any element then insert 0 for it. Examples: Input: 2->1->3->0->5 Output: 3- 15+ min read Insert Node at the End of a Linked List Given a linked list, the task is to insert a new node at the end of the linked list.Examples:Input: LinkedList = 2 -> 3 -> 4 -> 5, NewNode = 1Output: LinkedList = 2 -> 3 -> 4 -> 5 -> 1Input: LinkedList = NULL, NewNode = 1Output: LinkedList = 1Approach: Inserting at the end invol 9 min read How to copy linked list in Python? Linked Lists: Linked Lists are a type of 'Abstract Data Types' in Python. These data structures are linear in nature. Linked Lists are different from Lists as Linked Lists are stored in non-contiguous (non-continuous) memory whereas lists, in contrast, are stored in contiguous (continuous) memory bl 13 min read First non-repeating in a linked list Given a linked list, find its first non-repeating integer element. Examples: Input : 10->20->30->10->20->40->30->NULLOutput :First Non-repeating element is 40.Input :1->1->2->2->3->4->3->4->5->NULLOutput :First Non-repeating element is 5.Input :1->1 12 min read Traversal in Doubly Linked List Traversal of Doubly Linked List is one of the fundamental operations, where we traverse or visit each node of the linked list. In this article, we will cover how to traverse all the nodes of a doubly linked list and its implementation.Examples:Input: 10 <-> 20 <-> 30 <-> 40Output: 15+ min read Like