What is the space and time complexity of my code?
Hey your space complexity is O(n) because of recursion
And for Time complexity you are making call from BST(N) to BST(N-1)…BST(0) twice
so we can write T(n)=2(T(n-1) +T(n-2) +…T(1) +T(0))
say we write it as
T(n) =2*(T(n-1)+X)
then T(n-1) =2*(T(n-2)+( X-T(n-2) ) ) =2X
so this impl T(n)=23X=23*(T(n-2)+…T(1)+T(0) ) =23(T(n-2) +Y) and so on will give 2*(3^n)
So time complexity is O(3^n)
Hey @namangarg31
I hope your doubt is resolved ,if its then please mark it as resolved 
If its not then let me know the issue.
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.