Checking if a binary tree is a binary search tree or not!

preview_player
Показать описание
Check if a tree is bst or not: This video explains a way to check if a given binary tree is a binary search tree or not. I have explained the concept of a BST first along with the cases when you can call a binary tree as a Binary search tree!

Best Hindi Videos For Learning Programming:

►C Language Complete Course In Hindi -

►JavaScript Complete Course In Hindi -

►Django Complete Course In Hindi -

Follow Me On Social Media
Рекомендации по теме
Комментарии
Автор

First video in the whole of 72 till now jo nahi samjhaaa.

jerryray
Автор

This is the first video of this playlist which I don't understood clearly but Thank u Harry bhai for your efforts and hardwork for providing us quality content in this amazing DSA course ....❤️🙏

MrScientist
Автор

Sir please continue this course with graphs and hashing topics

madhavpaliwal
Автор

hii sir..many of us didnt understoood this bst concept.i really appriciate your efforts sir .can you update this video with another video with better explanation

triyoeducation
Автор

if anybody is having any problem understanding this video just do the dry run yourselves, you all will definitely understand the concept. i also did that and i understood . when you will do the dry run you will get to know that the first assigned value for previous is 1 which is the bottom left node, thats why the middle if condition ( root->data<=prev->data ) returns 0.

SumitKumar-nipj
Автор

those who hadn't understand this isBST function should first watch the next video then come here and watch again u will definatly understand

yogeshyts
Автор

Checking if a binary tree is a binary search tree or not : The program is bit confusing as it involves recursion, Can you please explain the code flow with a sample tree data. Will be more helpful for understanding,
Many thanks.

satishnadar
Автор

I was watched this video at least 8 times but it's worth . now i clearly understood this isBST function

First we clearing that
1) 1 3 4 5 6 is ascending of tree
2) Prev is NULL for root->data 1, prev is 1 for root 3, prev is 3 for root 4 and so on.
3) return 1 means true
4) return 0 means false
Note: draw tree and dry run

if isBST function return 1 ( true) means it is binary search tree and if isBST return 0 (False) means it is not BST

Now, if(! isBST(root->left)){return 0} this function pushing us to the left on the tree and if(! isBST(root->left)) is execute and return 0 only if isBST return 0.

That set i thing am explained all functions except recursion

aniketwakchaure
Автор

Please continue this playlist covering topics like graph, hashing, Greedy !
Pls pls pls🙏🙏🙏🙏🙏

nilarghyaroy
Автор

Simplified C++ code for those having problem understanding.
Add these functions in your program and run isBST(root) (dont forget to import vector library):

#include <vector>


//Appends the BST data into a vector by doing inOrder traversal
void inorderAppend(Node* root, vector<int> &arr){
if(root!= NULL){
inorderAppend(root->left, arr);
arr.push_back(root->data);
inorderAppend(root->right, arr);
}
}

//Checks if an given vector is sorted
int isSorted(vector<int> vec){
for(int i = 0; i < vec.size() - 1; i++){
if(vec[i+1] < vec[i]){
return 0;
}
}
return 1;
}

//Check if a Binary Tree is sorted using above functions
int isBST(Node* root){
vector<int> vec1; //Create a vector
inorderAppend(root, vec1); //Append into the vector inorder
return isSorted(vec1); //Check if the vector is sorted or not
}



//LIKE IF THIS HELPED (^_^)

vijetakumar
Автор

Who ever made this code originally is a genius! I could have never been able to make something like this.

content
Автор

Bro I have a doubt. While we are checking for the left subtree .. why aren't we checking for the right subtree if root->data <= prev->data is satisfied or not ?? Also the root -> data and prev->data point to the same node as u said that prev is the node whose children we are checking for??

hardiksrivastava
Автор

Sir literally app bahot sare rahasyon ka khulasa kar rahe ho, ab me kya hi bataun me to emotional hi ho gaya 🥺 ki itna acha content koi kaise de sakta hai😊

chocolyte
Автор

Brother I am a big fan of your Hindi.👍👍

coc
Автор

did not understand that function but I appreciate your efforts sir thanks_Sir💜⚡️

sanskarkumar
Автор

I agree that CodeWithHarry is the best teacher on YouTube.

sparshgupta
Автор

Best DS TREE playlist on youtube..Really great

SumitKumar-gmnc
Автор

Sir you are great and I am learning C language free of cost because of you.

srijanyadav
Автор

Thank you Harry sir binary search tree ka रहस्य batane k liye 🙂

PRATHVIRAJSINGHCT-
Автор

learned two new worrds today: Orderta and BSTta 😉😜

RiteshKumar-udbf
join shbcf.ru