There are two problems with Singly Linked Lists. One we can’t get back to the beginning of the list from the end. Second, we can’t go backwards through the list. Therefore, doubly linked lists and circular linked lists were invented.
Doubly linked list is a common variation on linked lists is to have two references to other nodes within each node: one to the next node on the list, and one to the previous node. Doubly-linked lists make some operations, such as deleting a tail node, more efficient.
- Allow sequential access to the list in both directions.
- Each element points to Next element and Previous element
Adding element to Doubly Linked List
When adding a node to the list at a given index, the following steps must be taken:
- Advance through the list to the node just before the one with the proper index.
- Create a new node, and attach it to the nodes that should precede and follow it.
There are 2 ways you can add a new element to an existing linked list.
1. addFirst Method: It adds an element before a specified (existing) element.
2. addLast Method: It adds an element after a specified (existing) element.
Removing element from Doubly Linked List
When removing a node from the list at a given index, the following steps must be taken:
- Advance through the list to the node with the proper index.
- Detach it from the nodes that used to precede and follow it.
1. Remove a middle element
2. Remove head element
3. Remove the only element
- Circular Linked Lists
- Selection Sort: A Graphical Explanation
- Bubble Sort: A Graphical Explanation
- Linked lists in C++
- Binary Expression Trees
- Queue Implementation in C++
- Binary Trees and Binary Search Trees
- Queues in C++
- Applications of Stack in Data Structures
- Introduction to Tree Data Structure
- Introduction to Graph data structure
- Binary Search Trees and Data Structure
Popular Posts (last 30 days)
- Circular Linked Lists 1300 view(s)
- Attendance Management Sys… 1065 view(s)
- Applications of Stack in … 1058 view(s)
- Graph Implementation in C… 904 view(s)
- Implementing Stack Data S… 775 view(s)
- Simple Currency Converter… 661 view(s)
- GRASP Design Patterns 501 view(s)
- Recursive Factorial funct… 490 view(s)
- Finding Minimum, Maximum … 364 view(s)
- Implementation of Priorit… 310 view(s)
TagsAndroid C-Sharp C/C++ language Classes Data structures Design Pattern Eclipse Game Development Graphics Design Books HTML iPhone JAVA JAVA GUI MIPS Assembly Mobile Programming Books Object Oriented PDF PHP Programming Programming Books Programming Languages Books Python RaphaelJS REST Source Code Threads Tutorial Web Development Books