In comparison to Single Linked List, Doubly Linked List is a version of Linked List in which navigation is available in both directions, forward and backwards. The following are some key terms to know in order to grasp the concept of a doubly linked list.
- Link - A linked list's links can each store a piece of data known as an element.
- Next - Each link in a linked list has a Next link that points to the next link.
- Prev - Each link in a linked list has a Prev link that points to the previous link.
- LinkedList - - A Linked List comprises the connecting links to the first and last links, referred to as First and Last, respectively.
Doubly Linked List Representation
The following are some key points to consider.
- A link element called first and last exists in a Doubly Linked List.
- A data field(s) and two link fields, next and prev, are carried by each link.
- Each link is connected to the next link via the following link.
- Each link is connected to its predecessor via the predecessor's predecessor's predecessor's predecessor's predecessor's predecessor's predecessor's predecessor
- To indicate the conclusion of the list, the last link has a null link.
Basic Operations
The basic operations enabled by a list are as follows.
- Insertion - It inserts a new element at the start of the list.
- Deletion - It removes an element from the top of the list.
- Insert Last - It is a command that adds an element to the end of a list.
- Delete Last - It removes the last element from the list.
- Insert After - It inserts an element after a list item.
- Delete - Using the key, delete an element from the list.
- Display forward - It shows the entire list in a forward direction.
- Display backwards - It displays the entire list in reverse order.