Given a 2D matrix, the task is to convert it into a doubly-linked list with four pointers that are next, previous, up and down, each node of this list should be connected to its next, previous, up and down nodes.
Approach: The main idea is to construct a new node for every element of matrix and recursively create it’s up, down, previous and next nodes and change the pointer of previous and up pointers respectively.
Below is the implementation of the above approach:
1 2 3 4 5 6 7 8 9
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Construct a linked list from 2D matrix
- Construct a linked list from 2D matrix (Iterative Approach)
- Construct a Maximum Sum Linked List out of two Sorted Linked Lists having some Common nodes
- Difference between Singly linked list and Doubly linked list
- XOR Linked List - A Memory Efficient Doubly Linked List | Set 1
- XOR Linked List – A Memory Efficient Doubly Linked List | Set 2
- Reverse a Doubly Linked List | Set-2
- QuickSort on Doubly Linked List
- Doubly Linked List Tutorial
- Reverse a Doubly Linked List
- Sort the biotonic doubly linked list
- Priority Queue using doubly linked list
- Rotate Doubly linked list by N nodes
- Delete a node in a Doubly Linked List
- Python | Queue using Doubly Linked List
- Reverse a doubly circular linked list
- Find pairs with given sum in doubly linked list
- Python | Stack using Doubly Linked List
- Sort the biotonic doubly linked list | Set-2
- Reverse a Doubly linked list using recursion
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : abhaysingh290895