Please likeeee, shareeee and subscribeeeeeeee :) Also follow me at Insta: Striver_79
@pritishpattnaik46742 жыл бұрын
My approach : TreeNode* searchBST(TreeNode* root, int val) { if (root == NULL) return NULL; if (root->val == val) return root; if (val < root->val) return searchBST(root->left, val); else return searchBST(root->right, val); }
@rollercoaster9719 Жыл бұрын
Same
@abhaykumarsingh38842 ай бұрын
Are auxialiary space use ho rhi isme
@CaseyXd-e3l2 ай бұрын
It will be log2n -1 auxiliary space right ? Please clarify
@sarangkumarsingh79013 ай бұрын
Awesome.........Trees mein pehli baar khud se kuch kiya.......
@aiartisry3 жыл бұрын
Almost about to finish free ka tree series... :) Thank you so much for such amazing content. Your hard work is appreciable. After watching a video I always try to explain in same way how you used to explain intuition and dry run each step. It helps me a lot and also increases my code quality by Looking at your code. 🙌
@satyapraneethkatta16523 жыл бұрын
This is best series on Trees I have ever come across on youtube. Striver salute to your passion and commitment to teaching people
@Anand-zg6jv3 жыл бұрын
bhai 1 no.content hai aur samjhaya bhut acche se hai ....bss abhi paid mt krna😂😂😂😂 plzzzzz abhi tree aadha hi pda hai aur graph poora baaki hai
@abhishekkumar-fe8lw7 ай бұрын
bhai konsi company ho tum abhi?
@shivangisrivastava11582 жыл бұрын
Thank you so much for BST !! Improving with every video.
@MandeepKumar-ue3zy3 жыл бұрын
BST can also have depth N(if tree is skwed) it's no always Logn height.
@takeUforward3 жыл бұрын
Yes it can be, but generally in all test cases it will be log 2 n, i have repeatedly used almost in all cases.
@tusharnain66522 жыл бұрын
That's where AVL trees come.
@niharika_0428 ай бұрын
thank you so much Vi 🙂I was almost to complete my tree series,the way of explanation i loved it a lot.
@iamnottech89184 ай бұрын
yes recursive solution is also easy and possible in case u are thinking
2 Line Java Recursive Solution Based on Same Approach : public TreeNode searchBST(TreeNode root, int val) { if(root == null || root.val == val) return root; return val < root.val ? searchBST(root.left , val) : searchBST(root.right, val); }
@Nikhil-Tomar5 ай бұрын
I think one correction should be there. The traversal time will not be log(N) for almost all cases
@iamnottech89184 ай бұрын
He mentioned that
@yusrax33 ай бұрын
in that case we have Avl tree to handle such scenario
@ganeshjaggineni40974 ай бұрын
NICE SUPER EXCELLENT MOTIVATED
@VivekSharma-eh2tv5 ай бұрын
sir 10 can also lie on the lesser part -> the point is to make the right node greater than the root's value so we can make the right node of any node 10 , that is how the lesser part will have the greater node . Please somehow reply if i go somewhere wrong
@enigmanarratives12 жыл бұрын
what about if we are given a linked list wont it be O(N) time comp ? like flatten binary tree Q we had all roots in right
@sudiptamukherjee82163 күн бұрын
WE CAN USE RECURSION ALOS.
@apmotivationakashparmar722Ай бұрын
Thank you So much !
@madetolaugh34762 жыл бұрын
Could someone please explain to me the difference between...... return searchBST(root.left,val); and searchBST(root.left,val) ? Thanks in advance
@tejas73792 жыл бұрын
In first case "return searchBST()" you will be returning whatever value your recursive call returns. Lets say I store a returned value in a variable, "val = searchBST()", and then return the val like "return val", what you are doing is returning what you got from function call. That in short is "return searchBST()". (Try to construct recursive tree on paper) For first case: 1 return [ function(root->right) ] right) ]
@piyushacharya76962 жыл бұрын
in short if you have a return type except void then add return fxn() or else fxn()
@himanshidafouty3474 ай бұрын
Understood
@paraskamboj10393 ай бұрын
thankyou sir ji
@shaiksoofi37414 ай бұрын
understod
@vaibhavpoliwal28203 жыл бұрын
Bro you are doing superb work, very very thanks
@dingo_59982 жыл бұрын
Thank you bhaiya for this😊😊😊
@spartant_12124 ай бұрын
Please include leetcode problem number in the description.
@Shivi325904 ай бұрын
thank you
@khitijkarmakar Жыл бұрын
Need help , after doimg this playlist is there any other type of trees i should also learn? (AVL RED BLACK Etc)
@UECAshutoshKumar Жыл бұрын
Thank you sir
@DevanshuAugusty Жыл бұрын
space complexity for this is O(1) ?
@herculean6748 Жыл бұрын
Could anyone please tell me where the articles from the sheet are??
@chiragbansod82528 ай бұрын
understood
@harshitjaiswal94399 ай бұрын
understood.
@shouvikdatta68312 жыл бұрын
Bro, is it preferred to use conditional operator in interviews instead of if else? Bcz the code looks complex using conditional operator.
@ganeshkamath892 жыл бұрын
Both are fine, as long as it is easy to read.
@ramavathnandhini2347 Жыл бұрын
thankyou striver ..🙌
@abhaythakur2597 Жыл бұрын
well explained
@Shivamkumar-xu6hu2 жыл бұрын
Good one
@nagavedareddy58912 жыл бұрын
Huge respect ❤👏
@abhijitkrao283 Жыл бұрын
If bool is to be returned instead of pointer, how can that be done ?
@iamnottech89184 ай бұрын
Recursion or in Iterative when null then false rest case true
@nileshsinha78693 жыл бұрын
Loving the series❤
@hitheshpk60302 жыл бұрын
UNDERSTOOD
@sujan_kumar_mitra3 жыл бұрын
Understood
@rishabhgupta9846 Жыл бұрын
understood
@ajayypalsingh2 жыл бұрын
💚
@sakshamsharma6482 жыл бұрын
great
@SibiRanganathL18 күн бұрын
Undetstood
@AmitKumar-je9qo3 жыл бұрын
Bhaiya....string ka lecture nhi bnega??
@t-anime517 Жыл бұрын
Understood 😊
@dreamyme5432 жыл бұрын
Understood:)
@piyushacharya76962 жыл бұрын
reach++
@momilijaz2712 жыл бұрын
done
@p38_amankuldeep752 жыл бұрын
💝🧡💝
@Telugu_europe2 жыл бұрын
US
@mohdhammadsiddiqui75982 жыл бұрын
Can anyone tell me the problem in this short code on the commented line if i am writing if instead of else if run time error (member access within null pointer ) is coming @takeUforward class Solution { public: TreeNode* searchBST(TreeNode* node, int key) { if(node==NULL) return node; while(node!=NULL && node->val!=key) { if(key>(node->val)) node=node->right; else if(keyval)) node=node->left;//comment } return node; } };
@psychointruder52032 жыл бұрын
because the value of node became null after the if statement in case if value was greater and not found ,and if you try to execute the next if there you dont have a check for the null node thus entering a null pointer, thats the reason i guess
@mohdhammadsiddiqui75982 жыл бұрын
@@psychointruder5203 got thanx , thanx for the comment
@theenglishclub9970 Жыл бұрын
what is the corrected code for your above code now? @@mohdhammadsiddiqui7598
@AbhishekSharma-ip4df Жыл бұрын
HEY Striver bro 😓😓please give back the geeks for geeks link beside every question. We have made hundreds of questions on GFG we started coding on GFG because it was in your sheet now if u only remove this how will we revise the question??????????? Now we have to search each question on GFG first then we are doing it, that is taking lot of time. If u have to put coding ninja link put it but don't remove GFG links.🙏🙏🙏🙏🙏🙏🙏🙏 GFG GFG GFG GFG GFG GFG GFG GFG GFG GFG GFG GFG GFG GFG !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@KaushikSharma-c3q Жыл бұрын
.....................
@adityapandey232 ай бұрын
Understood
@rishabhkumar81153 жыл бұрын
Bro you are doing superb work, very very thanks
@pratyush_7792 ай бұрын
understood
@tanishkumar6682 Жыл бұрын
understood
@jaiminsolanki54782 жыл бұрын
Understood
@rishabhkumar81153 жыл бұрын
Bro you are doing superb work, very very thanks
@NikhilGupta-zo5jh2 жыл бұрын
Understood
@rishabhkumar81153 жыл бұрын
Bro you are doing superb work, very very thanks
@roopeshn33012 жыл бұрын
Understood
@rishabhkumar81153 жыл бұрын
Bro you are doing superb work, very very thanks
@rishabhkumar81153 жыл бұрын
Bro you are doing superb work, very very thanks
@rishabhkumar81153 жыл бұрын
Bro you are doing superb work, very very thanks
@rishabhkumar81153 жыл бұрын
Bro you are doing superb work, very very thanks
@rishabhkumar81153 жыл бұрын
Bro you are doing superb work, very very thanks
@rishabhkumar81153 жыл бұрын
Bro you are doing superb work, very very thanks
@rishabhkumar81153 жыл бұрын
Bro you are doing superb work, very very thanks
@ritikgupta92383 жыл бұрын
bro are you getting paid for writing spammy comments?
@rishabhkumar81153 жыл бұрын
Bro you are doing superb work, very very thanks
@madetolaugh34762 жыл бұрын
Thanks bro
@rishabhkumar81153 жыл бұрын
Bro you are doing superb work, very very thanks
@rishabhkumar81153 жыл бұрын
Bro you are doing superb work, very very thanks
@rishabhkumar81153 жыл бұрын
Bro you are doing superb work, very very thanks
@rishabhkumar81153 жыл бұрын
Bro you are doing superb work, very very thanks
@rishabhkumar81153 жыл бұрын
Bro you are doing superb work, very very thanks
@rishabhkumar81153 жыл бұрын
Bro you are doing superb work, very very thanks
@parthsalat2 жыл бұрын
Are u using some sort of bot to do this? Pls tell...