Https://ide.codingblocks.com/s/159949

two test cases are wrong please help

Sarthak, the approach you were using in the code is correct, only there were few corrections that need to be made in the code, basically the output that needs to be printed must be in the sorted order, that was the only thing your code was lacking, so for that we can use the vector, and whenever you wishes to print the required nodes, you only need to use the push_back function to push the required
root->data, you can refer to this code, if you didnt understood anything, you can tell me, I have already made the corrections in your code, :