Check if a tree is bst or not
ฝัง
- เผยแพร่เมื่อ 7 ก.พ. 2025
- This video explains how to check if a given binary tree is a binary search tree or not in simplest way possible. I have explained the concept of a BST first (including the cases when you can call a binary tree as BST). After concepts, i have explained the algorithm for determining a binary tree to be a BST. CODE LINK is given below. If you find any difficulty or have any query then do COMMENT below. PLEASE help our channel by SUBSCRIBING and LIKE our video if you found it helpful...CYA :)
CODE LINK: drive.google.c...
Highest underrated channel in tech field. Hats off to your explanation.
Thanks :)
Now folks can tip, so vote with $$
I really don't know what these 8 dislikers want
This is such an awesome explanation!
I appreciate all the work you do, thank you so much brother
Welcome :)
@@trigger3012 bro optimization to ho phle normal navie approach to sikh lo
@@trigger3012 It's O(n) , every node is visited only once.
@@ashutoshtiwari4719 hold my backtracking
This explanation finally clicked for me. Thanks!
Great ❤️
This channel is like a motivation to all NON TECH college students that with determination you can go for tech jobs
👍🏼
Excellent explanation with examples 🙏🙏, thank you sir
Excellent explanation!!! thank you!
# 1 Like
plz upload video quickly
because i feel bored
when you are not uploding video
Bro i am home right now. Will upload quickly once I reach my workplace :) These are advance videos which i already made.
@@techdose4u OK
very well explained
Excellent explanation would be great also to see some Java code
Bro i dont know java. I need to copy it from somewhere but i cant explain if something goes wrong. That's why i don't upload java codes :(
System.out.print(checkBST(root, 0, 100));// print
bool checkBST(Node root, int min, int max) {
if (root == null) return true; // BST
if (root.value >= min && root.value
I more thing to coder, it'll work only with checkBST, isBST method from your source code should be removed.
very good explanation. do you have iterative solution as well?
thanks a lot.
Don't remember
best explaination
Thanks
this code is not working in gfg practice question
For a valid binary tree inorder traversal has to be increasing in nature right .. Can we do that ?
No. For an invalid case the inorder might still be increasing.
Thankyou sir, You are the best
Welcome :)
Excellent !
Thanks :)
do explain the coding also , explaination itself sometimes is not enough , we get stuck in coding sometimes. ,if possible add code in java also, not only c++
thank you !
Welcome :)
Great, but what about time and space complexity
Thank You
Welcome
Could you please help me to resolve the issues when root->right=NULL or root->left=root->data.
[2147483647,2147483647] what about this test case?
it would def fail.
You need to make modifications depending on constraint dude. If your value contains INT_MAX then either modify your if condition or take a larger MAX/MIN by using long. Simple.
Simply use :
Long min= -pow(2,31)-1
Long max= pow(2,31)+1
@@anupriyanishad why can't be done here
long min =INT_MIN-1;
long max= INT_MAX+1;
it is actually showing error
runtime error: signed integer overflow: -2147483648 - 1 cannot be represented in type 'int'
Please explain the code also...
If you face doubt in any part of the code then do let me know.
@@techdose4u if you don't mind, can you share the code through gist, or github , in the future videos maybe. Good night. Happy new year. 🎉
@@techdose4u if doubt, how should I let you know , through comments or any other way????
Same to you :)
Through comments. If i couldn't reply and it's urgent then you can use mail.
3:13