The question clearly states to print preorder traversal of the BST. And I have printed the same.
Please help me with the concept if I am wrong.
link : https://ide.geeksforgeeks.org/tD96sPY2JN
Build BST : What's wrong with my output?
@ayushjain.aj300
We are required to build not just any BST but rather a balanced BST. Since the data is given in sorted manner , if you simply build the normal BST as you have, it would always be a skew tree. We require a balanced BST for this problem which can be built by picking out middle element recursively from each part. Think about this method as it is kind of similar to Binary Search.
Sorry my bad,Sir.
I didn’t read the question properly I thought I just have to create a normal BST. Thanks a lot,Sir.
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.