I used a sorting technique to construct inorder array, will this take more than o(n) time?
Can u tell me whether my method is correct or not?
hello @radhika1995
both the methods will take O(n^2) time.
because the method u are using to construct bst from given preorder and inorder has time complexity O(n^2).
and the sorrting algorithm u are using has time complexity O(n^2)
so overall time complexity will be O(n^2)
i made some changes in the code is this now in O
yeah this is O(n) now