So as I already like a given into introduction or the overview, we will reduce the like ability by we need it. Right. So again, to like a cover that evil tree is nothing got like a self balanced binary tree. So why it is self balancing? Because in the case of, binary search tree so binary search tree y came because to efficient the searching part right so any node or any number you want to search okay you can search is easily like in the login time right and uh if let's say that is only a skewed tree okay if dst follow uh and we input in the order of like ascending or descending okay it will be like a skewed tree okay 10 20 30 40 okay okay if you insert in a bsd it will be like a skewed so again the time will be increased right so that's why like a evil tree comes into the picture so what it does is first it inserts those elements okay so wherever it see like it's not balancing or something or broken down like a breaking the balance it will be like a self-balance uh through its logic so eventually followed two rules okay like first of all it follows the bsd rules like as we know values smaller than the root go to the left and values greater than the root goes to the right it follows that and another condition is like it follows the balance factor like how the balance factor is calculated it's like a height of the left subtree minus height of the right subtree right uh so uh it is introduced by two scientists okay so uh their name is like a georgie adensal valiski and another one is landis so yeah so before or like going into that i want to introduce to something important but a basic height of a tree okay so as you can like you maybe ignore okay this topic but barely you know like there are two types okay if we follow like it was not coming from computer science background okay so why we need to calculate the height of the tree because uh in this balance factor only okay we need to calculate the height of a left subtree minus height of the right subtree it's like a recursive function okay so that's why we have to know how to calculate the height of the tree correct so again the height of the tree is uh the node so so sorry height of a node is a number of edges in the longest path from that node to a leaf node okay uh what do i mean okay so if you want to calculate this height of 30 okay so through these edges to the leaf node how much it is like a coming like if you calculate uh also like there are two approaches to calculate this okay if you calculate in edge-based manner so it will be like a two okay because we are calculating only the edges if you want to calculate in the node-based approach okay we may be ended up with the three because we are including this node also as a height okay so agar malo take care so let's say i'm writing something like a height 30 okay equals to 3 let's say i'm writing three okay so which approach i'm approaching is like a node based okay because height equals to one is here height equals to two is here height equals to three is here okay if i'm writing h of 30 is like a two okay i'm calculating in the manner of edges okay then in the case of a height of 10 is zero this is one this is two okay correct so uh so this is the two approaches okay so why i introduced because we write in the formula of this okay like a height of a node equals to one plus maximum of left height mine of and right height okay so why i written that because i also mentioned the longest path okay so longest path means we have to calculate also the max of okay that's why i mentioned the maximum of okay so why i added one plus okay why why like what's the reason and and if you see here like i also mentioned the base case okay so so let's say you don't have any like a tree right so i'm returning minus one okay and again i'm written here in the node-based approach zero okay so can't we write like this okay so something like there so so if you write okay maximum of left height okay so left height lineup height height market so certainly prettyarla may taste like you to 돼 it so very easily yep so many one playing figure one question and why we need that and if this formula is using both of the app it merger similar ok in the baseball match and if you see ok the base condition ok when you'll don't have any high ok so if the node is none means if you don't have any left children or you if you don't have any right children okay then i am returning minus one here okay means in this case it will return minus one okay in this case 25 it will return minus one okay if we follow the edge based approach okay so we don't have any edge right so that's why uh like a uh minus one why minus one can't wait can't i return like this zero because right so i don't have any anything so i can also return zero right why i'm returning minus one okay i'll come into that and if the node-based approach if you see here i'm returning zero here okay so it can make sense to you okay like a okay so you don't have any notes right you may return zero and if you are returning zero okay if we go in the node base approach take it i get node-based approaches now if you are returning zero then why you are writing height 3 okay why you are not writing height as a okay it may be like i told you okay because it is counting the rule or node also okay that's why you may be okay so can't i write it like this okay my formula here uh height of a node right height of node height of node height of node equals to max of okay uh one plus need along a man okay so for the basic look okay like a other economy in the layman term okay how he will think okay height of the left node or left subtree or height of uh sorry max of left height okay or right height i can also write like this right so i can also in the calculate like this and like this okay so in the layman term if you don't have any height then you return 0 or you calculate the height of a node you return like a max of left and right right so problem there is one problem let's say i have one node okay 10 only correct so if you calculate okay you're returning zero okay because you don't have any nodes right so let's say i'm adding one node like a thing like this okay and okay so there is one node okay simplify okay so i calculated okay so there is only one node it may be there left child or right child maybe we have only one child uh consider it as a left side because uh uls last along okay so left side may we have a one node left height okay and which is left height will be like a zero okay left height and right height of root 10 mei bol rahaun pehle mei ake calculate karke ja rahaun right height will be it will return zero okay when it will return zero it will also calculate okay so what is the maximum of maximum of left height left right now okay zero okay because it returns zero okay and right head get now it don't have any nodes zero means if you calculate we already have the height of 20 as a malaki one in the case of lucky one okay so it is returning zero if you see correct 10 is written in 0 because 10 height 0 higher okay so it will also okay what is the like either liquid okay left height we calculate in this manner right and the right height okay so left height and right height okay so what is the left height uh again like if we calculate in the research recursive zero because uh height of height of 10 is zero that's why it is zero okay so what is the right height zero okay it came like this so if we calculate the max zero is it like that no like a 20 is like he is having the height of one even though that we are getting zero so that's why we add one plus okay if you like a uh consider okay we are adding one plus okay then if we see like a there is a edge case here also like a this one okay i'm also copy that which edge cases this is like a uh edge edge node edge best approach okay it's best approach so if you see okay if you will go like this so now we will calculate the height of height of 10 height of 10 equals to 1 plus okay max of height of like a left side is none okay that's why we are writing minus 1 height of right side is none that's why we are are writing minus one so max of minus one is minus one so one minus one okay close to zero okay so that's how it came okay then i will write okay so in this approach okay if you see in this approach height of a 10 is came as a zero means perfect it came as a profit that's why we set it as a like a minus one hope you got it like a why we set it as a minus one here the edge base approach and then why we set it as a zero like a in the we also like we will go through it okay once evil tree comes there we will calculate iteratively like a height of the tree right so that's why now okay now we will go to the portion okay uh so there is a sample input called 30 20 10 okay which is in a descending order so if you will calculate it then it will go in the left skewed correct it will go to the left screwed yes we'll go to the left skewed then okay so there are four cases okay okay a build tree by the way i return so i've written here yeah so uh yes so another condition condition number two okay what i said is like a balancing factor height of tree okay so after you calculated the balancing factor use every must know every node must have balancing factor of minus one zero or plus one okay if the balancing factor goes out of this boundary then that node is not balanced you have to balance again okay by uh rotating okay so there are four cases introduced like a ll case rr lr and rl okay you already i think introduced to it okay so ll uh rr l rl okay correct so in the uh ll case ll case means what i have shown here like a 30 20 none okay in this so this will be like you have to do right right rotation so if you apply the right rotation it will be like 20 so hope you understand like how it will be and okay so after you rotate okay the rotation after rotation so if i want to show you before rotation 30 20 and okay so if you insert and follow the bst okay then it will be like this correct so if you will calculate the balancing factor okay so i'm going in it's the best approach okay so what is the height of a tree zero okay here doing column here so this is by the way height of 10 okay height of 10 is zero so like that okay height of 20 height of 30 okay okay so if you will go to a spaced approach then if you will end up with height balances too okay so this is out of boundary right so i want to reiterate to that point okay every node must okay so every node must have balancing factor of minus one zero or either plus one so here you will see uh it is like a two correct so it is out of boundary so so we have to see what is the case okay so from this node you will see this is going in a uh you have to see like a only two below nodes okay how it is going okay so it is going in an ll case okay because it is going in a left left okay rotation so left left case so you have to do right rotation okay by considering this as a mid node okay and you have to rotate like this okay so in a clockwise manner you have to rotate after rotation you can imagine the node is also balanced and it is follows bst okay how it follows the bst you will see the all the smaller node are like this all the greater node are in this correct so this is the ll case okay so this is also the easier one rr case 30 oh sorry 10 20 30 okay so you will see like before rotation it is like this okay if you will rotate to the anti-clockwise manner by considering the 20 as a mid node if you will point something there and you rotate just up one like a the 10 node to the right okay so then it is also will come like this okay also come like this okay so this is the rr case okay so in the lr case okay so unbalanced node i have to take let's say 30 10 20. if you will insert 30 10 will go to this and then it will something like this correct 30 10 20 okay so then you have to do first left rotation okay so we will consider first of all um so you have to like a t 10 20 okay left rotation okay then right rotation so it will be first like this okay 10 sorry 20 20 20 and then 10 after you left rotate okay after uh left rotate at node 10 okay it is like this okay then you have to do like this like the second rotation like a right rotation at a 30. okay so it's like a if you will see it's like a ll case right so after doing so it will come like this only um after right rotation yeah then in the rl case we'll take one example it is okay 10 30 20. okay so if you will insert then it will be like 10 30 20 okay so 10 30 20. so first of all you have to do the right rotation okay so after right rotation okay right rotation at 30 so it will be like 10 20 30 so if you will see this is a uh rr case okay so again it will come to the rr then you have to like a do the left rotation here so if you will do the left rotation then it will come like this got it so these are the four cases okay and above this you cannot expect anything any other cases next cases you can find any bigger trees okay so if you will take okay so we will take one example okay we will take one example like 30 20 40 10 by the way any doubt so far I have a doubt with respect to rotation so as we know that if any node which balance factor goes beyond 1 0 minus 1 then that that particular node is qualified to be rotation right yeah is my understanding correct yeah correct but how do we determine whether it should be rotated clockwise or anti-clockwise i mean this is the simpler example then we know that yes but if we let's say we have thousands of number in that case that's why i taken like taking this this one in the example i'll show you like uh how you can know i cannot able to take like a longer for the trial no no yeah it's fine i i just want to get uh understanding so in that case okay so so what all i take like three notes right so you have to you have to see see like a below two nodes where it is like a failing and on that you can see where he failed I don't know I'm we have two nodes, 20 and 10, so our rotation starts on 30, right? Correct, correct. So, we have 30 to clockwise rotate or anti-clockwise. How to decide? You can see which cases are aligned. Okay, so this case will be given. Right? This case will be given. this is my question is that we decide that we have to rotate clock wise you can say like let's say in the LL case this is a tree skewed left okay in the RR right side skew in the LR LR, something like this, and in the case of RL, something like this, something like this. So, you have to know from there, which case is. Okay. So, by observing the tree, you can be able to know which case it is, then you can apply with respect to that. Okay. And one more doubt is, there are two approaches, a node-based approach, and then we have the age-based approach. so while calculating the height so node based approach we take minus 1 lift nodes on the left node because it doesn't have any child null pointer so we give it minus 1 node based I'm sorry yes I'm sorry formula i have one plus max of uh left and right one plus no no no there are no one plus simply like this okay okay okay okay fine fine my bad formula if you could scroll this is yes fine fine what it thank you thank you because okay so it's cases are failing now you kindly explain in our case what you didn't understand uh so bosses our case because you have still doubt you raised your hand like you don't have any opinions okay so if you will see this example okay so i'll write first that thing okay so certainly like we will first make one class node okay then def innate values of sorry itself and you key data people know okay then self dot key so self dot key equals to the self dot right no sorry no no a l initial is not to hide zero okay so while considering a lift node has zero edges so so as i'm also following like it's based approach so yeah so that's why i given i can also write in the comment a lip node has zero it is so that's why i given zero here correct and then i'll calculate the height as i already shown ever i take one node okay so i have to calculate the height of that so i have to insert one node here in the function if the node is none then return minus one as is return node dot height okay so in the formula also how i am calculating the node node dot height equals to one plus max of height of node dot height of node dot left comma height of node dot right okay so this is how we can calculate the height of the node and then what else like a balancing cutter okay one minus three area. One second. You can return zeros. Correct. Otherwise return. Otherwise we have to return the height of node dot left minus height of node dot right and then what are the other functions yeah there is one functions would be insert function in the insert i'll take the root and then the key why i have to take the root because i have to compare with the root then i have to insert according to that because we are following the bst that's right so if root is one if root is none then return the node of t okay and then if t is less than root dot t dot left If I live is less than, sorry, is greater than root dot k, root dot write equals to almost note of return root yes okay so another thing i missed i forgot to tell you like after the rotation we have to also update the heights right so so so let's say this one is in for like a in the height of tube okay in the headspace approach height of tube after like a rotation okay what is the height height will be minus one correct so according to that we have to also update the height right so what we will do um insert oh yeah balance okay okay so there will be a update height also okay otherwise first we will take the left rotate okay so this is very important so So we will rotate right, we will rotate, so we will take that node, which we are like rotating. Let's say the node is Y, we just have to replace okay, we have to swap operation we have to do. okay in that case we will take one temporary variable x equals to right what it's going to come left this may be nice for now so we will take that left node and we will place in the temporary and we'll take another node and we will place the x dot left sorry it's not right here okay then x dot right it goes to y okay then y dot left goes to subtree and then here i will update the height also i like it iron okay this one 3d mounted so same like a formula to update the height also you just have to remember likely which height we have to update one plus max of height of x dot left height of x dot right then you have to return the x with this this is gonna be the same left rotate of x is gonna be right y dot left so if you lose up then it will be like a exact opposite of that So this is the purely opposite of this one. we will writing those four cases okay so if you will see like a there is no any i'm writing in a part-wise manner okay not like like also so we already calculated the balance vector right here this one so we will calculate the balance from balance equals to balance vector of root okay the balance is greater than one e is less than root dot left dot key okay then return right rotate okay This is the LL case. In the RR case, if the balance is less than minus 1, and the key is greater than right dot k and return the left rotate lr case first there will be a two case like a lr case mein pehle to left rotate hoega uske pada right rotate hoega right it balances. So value left rotate over balance must be greater than one. And if he is greater than root dot left dot k, no, not return. So first, the left rotate. So root dot left equals to, I will try and wait a second, then return the A to T to Q2. In the case of add-in, if balance is small, P is .y.k, then then write to .y.k and um so consider this all our cases under the insert function only because when we will insert then also we will calculate side by side which case it is so yeah this is all you don't have to remember calculate the idea. So I don't have to calculate. Yeah. Okay. Okay. So now we can now we can that example okay and try it on it so this is the example okay if you will like arrange okay so this will be something like this okay 20 40 uh 10 then 25 okay so this will be something like this okay okay correct so now the uh so if i will take the edge base then this will be 0th okay so method is zero here one man okay it's right one so it's going to okay correct so i calculated the height so i got to know that these are the heights of correct now which is imbalanced so 30 right again like if you want to calculate so from node 20 if you will calculate the height height of decade 20 will be 1 plus max of 0,0 so 0,0 of 10 is minus 1 right. So, if node is none, then minus 1 is minus 1. So, 1 minus 1 will be zero. Correct. So that's how for 25 also, it's same, the first 25, so I will be like a one plus max of 0, 0 will be height of 1. Okay. maximum height like a 20 say way of each of the branch for the next day it's like that so that will be one so or note that a so for note that a I talked that one plus max of left sub trigger height with my one hand mama 0 ZERO कैसे है, Right Subtree का ZERO ही आएगा, Right, क्यों कुछ नहीं है नहीं है नहीं तरह करके रिखाऊंग, So Just Replace 40 YEAR, Then Imagine, Correct, So अगर इसके Height आएगा तो हुआ है, Correct, So That's how this height came okay zero one two then this uh the valid uh avial balance vector remain like a minus one zero and plus one right right so then um then we will calculate the height calculator right so there to be all calculated the height inserted the node to the correct position then we will calculate the balance factor Okay, so the balance factor is also calculated, correct. And then it's got two, right? Well, right. One, two, so two is zero. Okay, height of right subject. So these are, you can say, okay okay so if you calculated the balance vector okay so i hope you can calculate the balance vector otherwise i can show one balance vector of node 30 okay so you can clear of all notes if you calculate the balance vector height of a uh left subtree height of a left subtree what what is the height of left subtree is proof correct okay so height of left subtree okay then we will calculate the height of of right subtree will be one two six seconds balance same okay no issues we are going to do a note to insert insert another note okay so this uh i'm sorry this example is already balanced okay so we will like insert another node into this only okay so we will insert 22. so i'll copy this okay so if you will calculate like a insert 22 22 25 22 so something like this okay so if you will see so which case is this okay so because i think you're asking okay so where it is breaking so here it is breaking right so if you will see from here okay then uh 22 25 20 so we have to first like a uh like from here okay okay if you will see the node structure something like this this correct that accent symbol right so if you will go on to the particular node so which case is this rl case right so node is something like this now if you will insert 22 right so then we have to first right rotate it then left rotation okay so so we will like calculate if you will calculate also the balance factor here okay so this is coming as a uh one taking one and then this will be coming as a two so this one is coming as a minus 1 correct so at a node uh 25 if you will calculate the balance factor uh it will be like a plus 1 correct and then uh if you will calculate the node at like balance factor at 20 then it will become as a minus 1 okay so here if you will like this come as a minus 1 and then this will be like a break okay yeah break over so node sorry no the balance factor will be like two okay and minus zero this will become as a so node 30 is now unbalanced because of 20 is 22 was inserted and then we must perform the left rotation then the right rotation right so if you will do the left rotation at 20 okay so just consider like this is like unbalanced okay so just two nodes only two nodes balance vector calculate so after like a calculate the balance vector just take the below two nodes 20 and 25 try to balance it okay if you want to balance so before the rotation it will be like a 20 and 25 right we will consider that only three three nodes okay then we will do first left rotation again because this is some kind of not rl case lr case okay lr case so in the lr case we will do the left rotation okay so okay yeah we are confused then what we are writing left rotate or left rotate so left rotate x and then y equals to x dot right okay sub 3 equals to y dot left okay so here x equals to 20 okay and then y equals to 25 okay that's it and then the subtree will be like subtree will be like a y dot left viker left man okay so if i will say then it will be 25 sorry 22 even y dot left x is like a 20 y x dot right so 25 then this is 22 again the then the link changes okay so the you will see the left rotate here this one again my copy got found again then we are stopping y dot left will be uh assigned as a x okay if y dot left will be assigned as x uh so 20 will be replaced by 25 correct so 20 will be replaced by 25 because y.left ko x kiya and then x.right ko subtree kiya okay start right ko order subtree kiya to pher ye oopar jayega 20 will be below 25 will be above only this one 22 okay something like this good for you then i think height will be calculated so height will be as usual calculated taken let's say x dot height calculate like x dot left x dot right it's going to change so it will be like that only okay so it will be like that only yes so this is how it will look like left rotation then again it will update the height taken height update uh so if you will see a height of the 20 will be 1 plus max of 0,0 over way one either you know like how to calculate the height ticket there is no any change okay then we will do the second rotation, which is right rotation at the node 30. So if we will do, so this one only right rotation. Okay. So something like this. So 25 will be forever. Okay. Then And here, okay, two will be here and then 40 will be here. So now if we will calculate again the balance vector, it will be as it is balanced. So this will be like a zero if we will calculate the balance, it's a balance that now left on this side, minus one, okay, it's a balance over zero, okay, 40, 40, it's 30, 20, I'm so this is how you will calculate so nothing just my other code so right rotate then I did some x equals to y dot left and subtree will be x dot right my y will be like 30 okay this this rotation se karna hai na this point se rotate karna hai na woh pahle pass karna pade ga like rotating from node 20 right first one okay so that i am passing as a x okay then mein abhi 30 se karna wala tha okay so that I am passing as a y, okay, like the value which I am passing in that function that I am talking about, then x will be my, so y I am passing, so x will be my y.left, okay, y.left means 25, okay, y.left, left, right, so, first, so, 25, then, what is it done, okay x dot right x dot right my question here on your next dot right is correct my question okay is correct with the 45 my particular children are okay okay okay this is correct my question here so that's why it is none then I am swapping the values okay and then I am swapping the values like x dot right equals to y okay and y dot left equals to sub tree so this is how i change the values s dot right may y a jayega merah so y a gaya taken by jopaleta 30 to x dot right question no game or white dot left making why i call left 2-3 the do so i will left my so this is why so y is like 30 30 ka left mein kuch nahi hai 30 ka right mein 40 hai 30 ka left mein is none so yeah so it is balanced so hope you understand so this is the main part only or kuch main nahi hai height calculate karna mahin hai after that I will also again calculate the height again then i'll again like a balance balance factor calculate again that balance will be calculated then it will stop there so it's kind of a recursive process so this is only the main part right protect yourself left protect yourself these are the two main things i think just so hope you got the pins of ability it's very hectic any doubt from this like the right rotate and the left rotate and it's my confusion like i just confused like a where to rotate i just see this pattern again uh in a bullet now because like i you have to see the pattern so like this is unbalanced so i'll take these three notes but not like that after that i calculated the balance vector okay this is balanced 20 balance would have to make you zone okay then i calculated the 30 okay 30 is in balance this then i should catch the 30 okay then i have to go the two below notes then i did that way so my bad don't go for the pattern kind of things okay as it's been fused here yeah so any doubt on this? go ahead Anil Jai if you scroll up once like you have done one rotation rate where you have got the maximum height not this uh there is a this one only like i did the first rotation the left rotation then i did this one yeah it's slightly uh okay i think from this example right you are asking i did this one because uh because i confused that because i've taken first yeah, this is what you have calculated height just above height up you have calculated 0 1 this one right so, we have health calculate 0 0 0 we have got 10 0 25 0 and then 40 pe bhi here pe koji leaf nahi hai to woh zero hi like calculated ho raha per jib 20 me a raha hai to it has got edge also and uuske movement me above right max of zero here pe ap ke pats 2 no pe zero hai but here pe 20 pe zero kuyo lik raha hai mujhe ye poochna tha because here pe already a leaf hai na it has 20 there is already two leaves left and right okay so what your doubt so at the 10 10 to 25 you don't have any further leave right so that is a like a null pointer but yeah and the 20 you have 10 and 25 20 have got the left one 20 also got the right one which is so i have to write two here and anyway i'm asking like why it is not uh uh why it is not as same as uh the 40 where obviously here right left right is like a 40 no okay let me repeat it why at 20 you have max of zero and zero that is the first question the first place even though we have the 10 that is a left which is already present as a sub leaf 20 there is also like 25 right so why we have max of zero and zero i first of all i followed the edge space approach okay what is the formula of height of a node can you tell just a second what is the height of form how i went not yes okay let me tell you okay what is the height of node I was asking but it can include in no issues this is the height of it mode okay left height left left so what is the left height here if i just calculate from 20 itself where we are 10 or 25 that is 1 leaves we have where height height 1 or 0 0 अगर calculate करके तो नहीं जहां पे 20 है ना अपने अपने अपने note 20 को हम select कर रहे है हम note 20 पे height detect कर रहे है तो note 20 पे जो left और right proportion है sub tree का उस पे height अमारी one आएगी यह जब calculate करेगा यह recursive है ठीक है यह recursive process I can calculate it. So, it's a return. Zero, because we have already calculated that height is this node height, correct? I think, we have no minus. Is it the right understanding? Yeah, I have to do that. That is okay. 40 to be same thing. We have to leave it. So, we have to do that. 20 to be left and right. So, I have to do that. So, I have to do that. So, I have to do that. I have to do that. Left and right. so this is zero because in local to local zero okay equation left rotation so left protest so we know that because i see the pattern that's what i told right I think if you have a balance factor check, 30 is how much is it? 30 is how much is it? 2 is how much is it? 2 is how much is it? 2 minus 0 is how much is it? So balance factor is how much is it? Sorry, sorry. But edge approach or node approach? oh okay ooh so that's why so that's why so left rotate I mean I hope 20 50 20 I am not like that I am not like that after rotation I can imagine in this way I mean rotate is nothing just swap just swap swap then numbers kind of left rotate sorry skewed one more question swap we have theory but different topic just relate I am trying to do this I am going to try to do this I have missed the previous concept but the reason to swap the existing value 30 is higher than 25 Here If I want to add 22 I want to balance I want to balance I want to see what is the nearest possible value where I can add 22 the same time मैं देख रहा हूं कि मैं 20 25 के नीचे आड करता हूं जैसे आपने की आये अरुट तो वह 25 के नीचे मैंने क्यों एड कियो कहीं और भी तो आड कर सकता था I'm going to be do I'm going to be there I'm going to be calculate as a strategy left I'm going to be lower value save left is replacing 25 and then 25 again right head 20 है है तो जब हम 22 को 25 से रिप्लेस करेंगे और 25 नीचे वाले में आएंगे तो 25 फिर उपर जाएगा वर 25 तो राइट है 20 का राइट है मतलब आप ऐसे समझ सकते है कि 20 पहले आपने बूला कि 22 जो 25 को रिप्लेस कि लिए त्रू हाँ 25 replace 20 which is last page 25 20 replace 25 already higher 20 25 20 replace 20 right rotation because already right 20 right 25 is a I can't I the right is 25 correct balance factor calculate this rotation because it is a sub tree rotation complete height update calculate the hole so something like I know it's about the height calculate is about the balance factor what's going on if not balance then find the case and balance it calculate the height and then calculate the balance factor and then calculate and then again check if balance or not this is I mean iteration movement here it now it's like a loop right right rotation right rotate so this is this is now you've got the point this is now you've got the point We have a code calculate then we will get it to a result. Okay, a sequence Okay Mm-hmm One last thing I know this question is here the output and the code and after left rotation after left rotation after left rotation this is one rotation now the tree we passed the right rotation we passed the whole tree we passed the whole tree we passed the correct 30, 25, 40 and 22 values now the present how do we do just for understanding present one array array 3.0. Sorry, sorry. Stack your form. Stack your form. Like 30,25. value. 30,25. Node class. Node. That's right. Left. Itself is a data structure. itself is a pop-identic data structure just for my understanding I just want to write like after the left rotation what is output as a what is output value only like a tree just for like a So that's how I can imagine you. Like you have written that example, 30 space, 40 space, like that. What I am trying to say. Now I have written that example, Aditya. This one, this one, just slow, slow, slow. 30, 20, 40, right? This one, you have created a tree. the same way left rotation what should be connected insert the same thing now we can read the tree left rotation what should be how we will read that read can you write it please once how's the output would look like this form after left rotation left rotation after left rotation correct after only left rotation not left rotation not after left sir okay I'm not sure can you take a control can you give me control you can't understand okay can you give me control any possibilities no okay we have so slow slows just this this this either this one so you example tree right this is example tree what i'm asking is can we read the actual value of output of left rotation in this way can we read it any time no no no no we cannot read it मतलब मैंने इस तरह से एक order लिया था तो मैंने इस तरह एक order लिया था इस तरह order लिया आपने अब हम left rotation के बाद क्या इस तरह का order उस particular example को read my output of a left case tree form i want to I started my tree I had a and here choose I do I do I do I am I I can extend the question, which is a small data. If we have a different data set, which is very big, millions of records, in case we have rotation movement, like where our blank and where our balance factor is, then we can easily imprint. We can assume that this has gone to a perfect level. to a perfect level because when you debug right level order in the level order okay okay okay thank you thank you so much okay thank you i'm stopping the control yeah hi because So basically, my question was similar to what Anujay asked, but if we combined all the concepts together, it's very difficult to visualize it currently. I don't want to go in order then I'm going to go in order then I'm going to go in order in a given tree and then we will calculate the height of given tree correct and then we will calculate the balance factor or and then we will have our if else statement will remain if balance then find the case and then again check if the balance is not so iterative process means case which is your statement it will execute every time until and unless our tree we can balance 0-1 okay and initialize so do we pass the sequence of elements which we have made five or ten number When we create a node class, do we pass these numbers as an input? Yes. Where are we pass? In the node you can write. You can write something. I will tell you a little bit. high level value in values or something like that value in values of input language and input of it is string over for almost a mapping currently around values then we thought a new list of map and both values in the values for i value in the values will is a free affair i in values before the simplification tilde n, starting from 0, index tilde n, means n-1 तक जाएगा, फिर आप insert function को call गर सकते है, insert of root, comma i, and ok I So in that case, the root will have the first thing to do if we have the tree. Do you understand what I mean? Basically, the tree is given. Let's say we have a BST tree. So that tree will have the node. So the tree will have some insertion. The tree will not be given. Something like that. The tree will have some insertion. So first we will make the tree. How do we create a tree? How do we create a tree? Okay My assumption is that a tree has been given and then we are asked to insert a few elements Yeah, yeah I mean a little confusion Okay So basically you will initialize and then you will keep on inserting element-wise left and right adjustment element then I'm in the insert function only I'm initializing this one yeah node initialize okay sir a question is so basically we have height calculate we don't have any tree and we are inserting an element that will become our root element right and then we will calculate that height I hope you can understand. ii regarding now there is also a visualizer left okay three node uh where my calculate that node basement this is in balance stop up my height calculate right more of right imbalance may balance right you to hide the car joe one two three like over node-based approach side the photo and use the very dicey shan kashrap it's also for me then the outer level now the right rotation the original situation based on the pattern balanced factor based on balanced vector not based on pattern uh my bad i told you like a choose from the based on pattern okay so based on balance vector thanks okay that's it for today i think we can close the class yep thank you everyone thanks