Can You Please explain me this Question. https://www.geeksforgeeks.org/construct-a-doubly-linked-linked-list-from-2d-matrix/

Can You Please explain me this Question.

I dry run the same matrix and I made like
1->2->3->NULL
Then from 3 down call will be there to 6 and from 6 2 calls will be there one for right that will be for NULL and second one for 9.
Then 9 also will have 2 calls but both for NULL.
Then It will return to 6 then to 3 and at last it will reach to 2 and then one call for 2 is left that is downward so it will make call to 5 and 5 will again make 2 calls and there too one will be for 6 and new node will be made and prev and temp will point there.
Here I am stuck that how 2 6’s are possible and there too up and prev are pointing to different ones.

Hey @cbcao263
Yup u are right according to this solution there will be multiple copies for some nodes

But see how we are printing and it will only print the nodes of matrix once.
If u want to create single copies u can use hashmap where i,j point to created node and u can use that to connect all the nodes .

Sir can you please tell me asap
How is display function working.

We take node at 0,0 and keep moving towards right as long as we are getting nodes
Then we mive to node of 1,0 and do the same
And we keep doing this until our down pointer is not NuLL

Sir as you told there will be multiple nodes of 6 and I dry run it accordingly and there are many multiple nodes.
How that will be treated then.

Create the DLL according to the above function (do it for 2×2 matrix) ,and you will understand how its working

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.