Bst to sorted link list

why this ques cn’t e solved using inorder traversal?

so why are we doing postOrder traversal?

i mean what’s the benefit of postorder traversal over inorder? what’s the time comp in both cases?

at time 10:50 arpund sir has written linkedList leftLL = flatten(root->left) leftLL.tail->right = root ? what does that mean?

can u pls explain the code once

Hi Archit
At one thought you might think this way,
But consider, the scenarios where only left subtree exits, or only right or none of them exist.
You will have to find the sorted linked list of both the left and right sides before working for the root i.e
you need to go with postorder traversal only(consider the below thing regardless of the data type):
Node *head1=constructBST(root->left);
Node *head2=constructBST(root->right);
Then you will have conditions like:
if(head1&&head2)
if(head1)
if(head2)
then the else part when none of head1 or head2 exists
Let me know if you got it the right way?

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.