Largest Binary Search Tree in BT | C++ Placement Course | Lecture 28.10

  Рет қаралды 40,505

Apna College

Apna College

Күн бұрын

Пікірлер: 125
@amayatre3558
@amayatre3558 3 жыл бұрын
That's what we all wanted from start ❤️❤️Make videos of longer duration but explain properly. This was best, perfectly explained. ❤️
@willturner3440
@willturner3440 3 жыл бұрын
Only and Only in apna college, hats off to the great ma'am
@krishnanarwani8105
@krishnanarwani8105 3 жыл бұрын
Bohot hi pyara concept...Maza aa gya... Kya toh samjhaya he...Waah
@ShubhivDogra
@ShubhivDogra 3 жыл бұрын
this course made me answer all the interview qns asked in my college campus placenment -- 14lpa-gap
@sakshamjain3775
@sakshamjain3775 3 жыл бұрын
@Shubiv Dogra what were the questions based upon??
@ShubhivDogra
@ShubhivDogra 3 жыл бұрын
@@sakshamjain3775 based on stacks and linked lists..
@rahul_ji21
@rahul_ji21 3 жыл бұрын
@@ShubhivDogra congrats
@sumitKumar-pf9xo
@sumitKumar-pf9xo 3 жыл бұрын
Congo bro 🤗🤗🤗
@chanduchandrakanth5131
@chanduchandrakanth5131 3 жыл бұрын
Bro Which clg r u from?
@sudhanwapande2040
@sudhanwapande2040 3 жыл бұрын
Bohot aala samjhaya aapne.. itna tough concept ko easy kardiya🙏
@PankajSingh-vi3fy
@PankajSingh-vi3fy 3 жыл бұрын
love that music of keyword.. so satisfying 😌
@upasanapan1790
@upasanapan1790 3 жыл бұрын
struct Info { int size; int max; int min; int ans; bool isBST; }; if(root==NULL){ return{0,INT_MIN,INT_MAX,0,true};//will only come here if already traversed left and right / left is NULL so we put INT_MAX in rightInfo.min as null means it has to be greater than root in all cases and we put INT_MIN in leftInfo.max as null means it has to be less than root in all cases. LOOK ORDER IS REVERSED FOR max and min AND INT_MIN and INT_MAX. } p.s IT took me 3 days to realise this.sed life
@beenaasha506
@beenaasha506 3 жыл бұрын
Great explanation
@satyam5036
@satyam5036 3 жыл бұрын
Who noticed this is dynamic programing on trees to avoid repetition
@lokeshdulani6035
@lokeshdulani6035 3 жыл бұрын
fucking awesome far better explanation than content available at other sites
@avronilbanerjee5302
@avronilbanerjee5302 2 жыл бұрын
didi you are a legendary person !
@adityabhandari6688
@adityabhandari6688 3 жыл бұрын
great explanation mam, this is what is called perfect explanation
@devilronak7262
@devilronak7262 3 жыл бұрын
op, heads off to this video, what a great explanation, jod or what?
@devilronak7262
@devilronak7262 3 жыл бұрын
@@utkarshverma2604 😂😂😂
@its_neel_ok
@its_neel_ok 3 жыл бұрын
@@devilronak7262 ya toh pubg wala ha kaya.....xD
@devilronak7262
@devilronak7262 3 жыл бұрын
@@its_neel_ok 😂
@its_neel_ok
@its_neel_ok 3 жыл бұрын
@@devilronak7262 xD
@devilronak7262
@devilronak7262 3 жыл бұрын
@@its_neel_ok xD
@rajveerbari791
@rajveerbari791 Жыл бұрын
COOKING 🍳 AND SERVING(TEACHING) US AT THE SAME TIME🤣 We can hear 👂 the cooper's whistle behind.
@hustlewithVaibhav
@hustlewithVaibhav 3 жыл бұрын
Thank you 🙏🙏
@shreyankshrestha9274
@shreyankshrestha9274 3 жыл бұрын
bahut sahi ❤❤
@Zeno_Yoru
@Zeno_Yoru 3 жыл бұрын
Vaiya. Lecture 28.9???
@SubhamKumar-fr7gw
@SubhamKumar-fr7gw 3 жыл бұрын
paikhana kare me t ek number bate e log
@NiteshSingh5375
@NiteshSingh5375 3 жыл бұрын
I think last statement spoken by tutor is not correct. Ans=2 because of max. BST found is due to 20 & 5 but not 15&30. we can not take partial(one side either left or right) Binary tree to accept it as a BST.
@nazeershaik9812
@nazeershaik9812 11 ай бұрын
#include #define ll long long #define loop(i,n) for(int i = 0; i < n; i++) #define loop1(i,n) for(int i = 1; i left); vector rt = help(root->right); vector curr (5,0); curr[3]=1+lt[3]+rt[3]; if(root->data>lt[1] && root->datadata,lt[0]); curr[1]=max(root->data,rt[1]); curr[2]=1; curr[4]=curr[3]; return curr; } curr[4]=max(lt[4],rt[4]); return curr; } int largestBST(Node* root){ return help(root)[4]; } int main() { Node* root; cout
@ritwickrana3255
@ritwickrana3255 2 жыл бұрын
as i am moving forward in this course no. of likes are and views are decreasing i guess they are not able to continue in this journey
@tarunbisht8016
@tarunbisht8016 3 жыл бұрын
I don't think there is any need to check whose value is minimum left info, right info, and current root value, cause it's obvious that left info's min value will be min and if it is not the case then it's not a bst.
@naiyerabbas6481
@naiyerabbas6481 3 жыл бұрын
Yeah!! I was also thinking about it.. We don't need min and max
@avronilbanerjee5302
@avronilbanerjee5302 2 жыл бұрын
@@naiyerabbas6481 no you have to check what if the left or right child is NULL ?? then the min would be different
@letsdoeverythinginoneweek9398
@letsdoeverythinginoneweek9398 3 жыл бұрын
IF ROOT ==NULL IT NOT ONLY SATISFY THE NO NODE CONDITION BUT IT ALSO SATISFY THE LEAFT NODE CONDITION
@pekkingjackal1180
@pekkingjackal1180 3 жыл бұрын
Yes,you are right but I cannot understand the logic, can you please explain it?
@SagarSagar-ym5wx
@SagarSagar-ym5wx 3 жыл бұрын
very good
@maneshwarsingh8688
@maneshwarsingh8688 3 жыл бұрын
19:55 Wouldn't curr.min = leftInfo.min and curr.max= rightInfo.max directly be applicable instead of comparing with root->data since the said root is already validated to be a BST! So leftInfo.min would always be less than root->data (heck, root->data is greater than leftInfo.max too) and similarly for curr.max also.
@sameeryadav8857
@sameeryadav8857 3 жыл бұрын
yes i also think so... that was not necessary...
@piyushlohiya1977
@piyushlohiya1977 3 жыл бұрын
I also thought that and it is correct!! What she said is just unnecessary
@nishantchauhan2596
@nishantchauhan2596 3 жыл бұрын
@Maneshwar Singh No brother we need to do that. Consider a case where a node has only right subtree than in that case curr.min=leftInfo.min will not work because now curr.min is root->data.so we need to that. Though that whole line is not required this will do the work curr.min=min(leftInfo.min , root->data)
@adarshdubey1784
@adarshdubey1784 3 жыл бұрын
Bro , I asked same doubt in comment section and then I started to search if someone has encountered same doubt or not, then I found you ....So, I think There is no need to write that lengthy stuff
@Subhankar415
@Subhankar415 3 жыл бұрын
@@adarshdubey1784 There is a need. Look at the comment above
@hardikagarwal7652
@hardikagarwal7652 3 жыл бұрын
curr.min and curr.max ko if statement ke bahar hona chahiye
@vinaydangayach386
@vinaydangayach386 3 жыл бұрын
yes but dont know why this code is not giving error?
@chirag-sg4kd
@chirag-sg4kd 3 жыл бұрын
same doubt but agr bahar rakh rahe hai to ans 1 aa raha hai
@sanketbhagat1222
@sanketbhagat1222 3 жыл бұрын
@@chirag-sg4kd nahi, bahar rakha to 2 aa raha hai. agar 20 to 10 se replace kiya jai to 4 ata hai, means min, max ko if ke bahar rakhne se sahi output aa raha hai..
@piyushlohiya1977
@piyushlohiya1977 3 жыл бұрын
@@sanketbhagat1222 if ke bahar bhi aur andhar bhi hona chahiye
@TUSHAR-mj1en
@TUSHAR-mj1en 3 жыл бұрын
@@vinaydangayach386 dekh bhai min max ko update karne ka koi fayada nhi h kyuki jab isbst false h to bade wale if condition bhi false hoga uka min max kabhi bhi compare hoga hi nhi bro aur uske karn ab uss node to milakar kabhi bhi answer nhi banega
@vaibhavbelekar4653
@vaibhavbelekar4653 2 жыл бұрын
Student : Notes de de Thakur......
@adarshdubey1784
@adarshdubey1784 3 жыл бұрын
I have doubt on line no.37...if current node is BST then on line no.38 the minimum value of current node should be "minimum value from left subtree", as we mentioned left subtree is also bst ..?
@cenacr007
@cenacr007 3 жыл бұрын
it's a recursive approach, think in that way, will your logic work in case of leaf nodes and nodes with only right subtree. think for one node, the last one and slowly move upwards, don't pick random node and only think about it.
@namangoyal8477
@namangoyal8477 3 жыл бұрын
Excellent
@AdarshSingh-on5fy
@AdarshSingh-on5fy 3 жыл бұрын
#include using namespace std; class node{ public: int data; node *left; node *right; node(int d){ data=d; left=NULL; right=NULL; } }; class bst{ public: int size; int max; int min; int ans; bool isbst; }; bst largestbst(node * root){ // root is null and size is 0 if(root==NULL){ return {0,INT_MAX,INT_MIN,0,true}; } // leaf node condition if(root->left== NULL and root->right ==NULL){ return{1,root->data,root->data,1,true}; } bst left=largestbst(root->left); bst right=largestbst(root->right); bst curr; curr.size=(1+left.size+right.size); if(left.isbst and right.isbst and left.maxdata and right.min>root->data){ curr.min=min(left.min ,min(right.min,root->data)); curr.max=max(right.max ,max(left.max,root->data)); curr.ans=curr.size; curr.isbst=true; return curr; } curr.ans=max(left.ans,right.ans); curr.isbst=false; return curr; } int main(){ /* 15 / \ 20 30 / 5 */ node *root=new node(24); root->left=new node(20); root->right=new node(30); root->left->left=new node(5); cout
@Saurabh-gg9lv
@Saurabh-gg9lv 2 жыл бұрын
int max and int min
@santoshbhupati3579
@santoshbhupati3579 3 жыл бұрын
Thankyou
@royal_bettiah22
@royal_bettiah22 3 жыл бұрын
Nice Sir
@hardikagarwal7652
@hardikagarwal7652 3 жыл бұрын
15 and 30 will not be a BST
@AmrutanshuMishra-dp1mf
@AmrutanshuMishra-dp1mf Жыл бұрын
i had a doubt when we are updating the value of our curr minimum and maximum cant we simply just say curr.min=left.min and curr.max=right.max as we are checking if the current node is a bst before this ??????
@uxxrhiiikgfdsdvhj
@uxxrhiiikgfdsdvhj Жыл бұрын
exactly my point
@sanjayswami1155
@sanjayswami1155 3 жыл бұрын
i think there was no need to right extra conditions for the leaf nodes and it will automatically get calculated , anyone correct me if I am wrong
@pulkitmittal584
@pulkitmittal584 3 жыл бұрын
yes
@sanketbhagat1222
@sanketbhagat1222 3 жыл бұрын
Mam, please correct that, curr.min & curr.max if ke bahar hona chahiye..
@piyushlohiya1977
@piyushlohiya1977 3 жыл бұрын
Kyo?
@Subhankar415
@Subhankar415 3 жыл бұрын
Does not make a difference anyways. for the other case, you will not be using the values anyways
@shauryashekharsahu7485
@shauryashekharsahu7485 3 жыл бұрын
Aman bhaiya unacademy m aap padhayenge ya nhi plz bataiye mai bura fas gya hu
@vansh6368
@vansh6368 3 жыл бұрын
🙂😂
@omkarmhaske8120
@omkarmhaske8120 3 жыл бұрын
comment 0
@willturner3440
@willturner3440 3 жыл бұрын
At last why we are not set the value of curr. Max and curr. Min
@shubhamgoel3998
@shubhamgoel3998 Жыл бұрын
int largestBst(node *root,int *Max,int *Min,bool *isBst) { if (root==NULL) { *isBst = true; return 0; } int lMax,lMin,rMax,rMin; bool isBstLeft,isBstRight; int left = largestBst(root->left,&lMax,&lMin,&isBstLeft); int right = largestBst(root->right,&rMax,&rMin,&isBstRight); *Max = root->data; *Min = root->data; *isBst = true; if (isBstRight == false || isBstLeft == false) { *isBst = false; return max(left,right); } if (root->left!=NULL) { if (lMax > root->data) { *isBst = false; } else { *Max = max(*Max,lMax); *Min = min(*Min,lMin); } } if (root->right!=NULL) { if (rMin < root->data) { *isBst = false; } else { *Max = max(*Max,rMax); *Min = min(*Min,rMin); } } if (*isBst == false) { return max(left,right); } return 1+left+right; }
@divyanshugautam2304
@divyanshugautam2304 3 жыл бұрын
cant we do it like take the inorder then the largest sorted sub array of preorder is no of nodes of largest bst
@adityaagarwal3511
@adityaagarwal3511 2 жыл бұрын
why we haven't used public in the structure info
@pranjalrajput2886
@pranjalrajput2886 2 жыл бұрын
Lecture 28.9 is Missing
@its_neel_ok
@its_neel_ok 3 жыл бұрын
what is the meaning of ans in the list when explaining isn't it the size of the largest BST...then how come it is equal to the root??? I didn't understand that
@anonymouspromax
@anonymouspromax 3 жыл бұрын
28.9 lecture??
@lavyadav2396
@lavyadav2396 2 жыл бұрын
I think on line no. 41 there will be change ----->>> curr.ans = max ( curr.size , max ( leftinfo.ans , rightinfo.ans ) );
@Rohan-ov3fr
@Rohan-ov3fr 3 жыл бұрын
Bhai kuch samjh bhi aaya kuki mugje ek baar me kuch ni aaya 🥺🥺
@depression_plusplus6120
@depression_plusplus6120 3 жыл бұрын
Itna easily samjhaya hai fir bhi agar samaj na aaya plz revise kare apni basics
@AlokSingh-jw8fr
@AlokSingh-jw8fr 3 жыл бұрын
Can anyone please explain me at 12:24 di has made a constructor in structure how's it possible constructors are to be made in classes???????
@vasukotadiya6235
@vasukotadiya6235 3 жыл бұрын
In C++ we can make constructors in structure... You are right but in C language
@adityabhandari6688
@adityabhandari6688 3 жыл бұрын
bro watch full video, it was an error which she corrected at the end
@NareshKumawat-w9z
@NareshKumawat-w9z Жыл бұрын
this is not applicable in all conditions
@PegasiuuuS
@PegasiuuuS 3 жыл бұрын
Can't we just find inorder traversal and check for size of longest increasing sub array in that inorder traversal
@azeezmoiz9195
@azeezmoiz9195 3 жыл бұрын
It doesnt work that way take a sample input from GFG and dry run your logic
@tarunbisht8016
@tarunbisht8016 3 жыл бұрын
@@azeezmoiz9195 No, i think it will work perfectly just space complexity o(n) ho jayega
@tarunbisht8016
@tarunbisht8016 3 жыл бұрын
@@azeezmoiz9195 even we can do it without using any vector also
@promphotos5403
@promphotos5403 3 жыл бұрын
@@tarunbisht8016 naah, we can have a case in which two bst subtrees can be combined to give a sorted subarray in a inorder traversal array.
@SagarSagar-ym5wx
@SagarSagar-ym5wx 3 жыл бұрын
ma'am please send the source code
@jaydalsaniya6986
@jaydalsaniya6986 3 жыл бұрын
Avaaz bohot Dabi dabi lagg rahi hai
@Priyanka_Aarna
@Priyanka_Aarna 3 жыл бұрын
First one 😊
@tanmayjain8542
@tanmayjain8542 3 жыл бұрын
1st comment
@ayushbankia9004
@ayushbankia9004 3 жыл бұрын
Anyone 12th pcm?
@pathikshah
@pathikshah 3 жыл бұрын
JEE me kitne aaye ?
@ayushbankia9004
@ayushbankia9004 3 жыл бұрын
@@pathikshah bhai bahut kharab aye. 96.2.
@pathikshah
@pathikshah 3 жыл бұрын
Toh padhna JEE ka, idher kya kr rha hai? DSA college me bahut time milega..
@girishporwal5183
@girishporwal5183 3 жыл бұрын
@@pathikshah lol
@piyushbansal9716
@piyushbansal9716 3 жыл бұрын
@@pathikshah LMAO
Recover Binary Search Tree | C++ Placement Course | Lecture 28.11
20:49
When Cucumbers Meet PVC Pipe The Results Are Wild! 🤭
00:44
Crafty Buddy
Рет қаралды 60 МЛН
Lazy days…
00:24
Anwar Jibawi
Рет қаралды 6 МЛН
ТВОИ РОДИТЕЛИ И ЧЕЛОВЕК ПАУК 😂#shorts
00:59
BATEK_OFFICIAL
Рет қаралды 6 МЛН
Delete a node from Binary Search Tree
18:27
mycodeschool
Рет қаралды 1,1 МЛН
Learn Binary search trees in 20 minutes 🔍
20:25
Bro Code
Рет қаралды 184 М.
Deletion in a Binary Search Tree
22:42
CodeWithHarry
Рет қаралды 199 М.
L52. Recover BST | Correct BST with two nodes swapped
15:56
take U forward
Рет қаралды 134 М.
Lecture 73: Largest BST in a Binary Tree || C++ Placement Series
23:09
CodeHelp - by Babbar
Рет қаралды 87 М.
Binary Search Tree in Python
22:59
NeuralNine
Рет қаралды 54 М.
Binary Tree in Data Structures | All about Binary Tree | DSA Course
1:22:13
When Cucumbers Meet PVC Pipe The Results Are Wild! 🤭
00:44
Crafty Buddy
Рет қаралды 60 МЛН