Segmentation fault while converting BST To DLL

Hi, I have written code for converting BinarySearchTree to DoublyLinkedList, but I am getting a sengmentation fault for some test cases like - [9,32,21]

Can someone help me what is the problm in my solution ?

Here is the link of solution I have written - https://ide.codingblocks.com/s/442704

hello @maheshghamand
once try submitting over leetcode

also in the question u r asked to create circluar doubly , as per your logic, it will create simple dll.

check now->

I am making it circular, by attaching it’s ends in my solution on line no - 127

yeah i found it later.

here ur updated code->

thanks for the modified solution, I will review where I have done mistake.

Thanks for the help, I understood that the problem was due to node-by-reference which leads to the problems when I am updating node->left = last. :+1:

yeah . . . . . . . . . . . . . . . … . …

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.