Doubt in approach

To access every value in preorder array, we will require O(n) complexity , so we have to do insertion in O(1) time? What is the approach

Hi @nishchay-verma… I didn’t get what exactly is ur doubt… can u pls elaborate…

I have to build a BST from preorder array right and to access each element of preorder array it will take o(n) complexity and for each element i have to insert it in such a way that the overall complexity is O(n) how i can do this
what is the approach for this problem

Hi @nishchay-verma… sry for such a long delay… i don’t know I missed ur doubt…
well u can refer to this article https://www.geeksforgeeks.org/construct-bst-from-given-preorder-traversal-set-2/ u will find very good explanation and code as through chat it is not possible to explain the whole logic…

ok…

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.