[00:00:08] Okay, so in BST we identified a problem of skewness and of course just giving a quick review that BST follow this order that is left will always less than the root which is always less than the right. [00:00:28] So this is the, you can say property or this is the thing that the binary search tree follows. [00:00:37] And this, for maintaining this property, you do need not to bother about anything, just [00:00:41] bother about three nodes, let us say root, this is left and this is right. [00:00:49] If we find this property is holding everywhere, then there is nothing to worry, automatically [00:00:54] the entire tree that is formed will hold this property. [00:00:57] just pick any three node if it is following left less than root less than right then we can easily [00:01:04] say that the tree becomes the binary search tree starting from the root to the leaf then [00:01:14] we were discussing about the difference between left height and right height that is defined as [00:01:19] the balance factor okay and here the if you see here so it indicates the value could be zero or [00:01:26] one but if you remove the mod value okay or we when we do a difference between tree left height [00:01:33] minus difference between tree right height so it could be max zero one or minus one that is there [00:01:39] okay now when we talk about the operations that is performed over the tree so they are insertion [00:01:49] deletion searching and traversal okay so traversal where we have to widget the node and in searching [00:01:57] we have to identify a specific item of interest. Okay. So, if you compare the searching criteria, [00:02:04] so we are not actually modifying the structure of the tree. So, whatever the searching criteria [00:02:08] that we adopt in binary search tree will be same for the AVL as well. Similarly, for traversal, [00:02:15] it is similar to that of BST. But when we do insertion and deletion, so there will be change [00:02:21] the balance factor that is the difference in left height and right height will disturb for example [00:02:28] here if you can see when we are inserting a new element e in the existing tree [00:02:36] then what we find we find the balance factor of node g and c changes okay so to overcome such [00:02:44] changes we have to perform certain rotations that we have already covered in the last class [00:02:49] okay and one important thing is that the rotation point will be the first node from the [00:02:57] point of insertion okay here it is also written the rotation will happen on the first node who [00:03:05] is violating the balance factor property will be act as the cent then we discuss about different [00:03:13] type of rotations when we insert a node on the left of left sub tree then we have to perform [00:03:19] LL rotation. When we insert on the right of right subtree, then it is called as RR. [00:03:26] And similarly, when we insert on the left of right subtree or when we insert on the [00:03:32] right of left subtree, so LR and RL rotations are performed. So, these rotations we have already [00:03:40] seen. So, LL if you see when we are inserting into the left of left subtree, so we have to [00:03:48] identify the node that violated and do the rotation around it so a goes down b comes up and [00:03:54] this one then we have also seen one example so when we try to insert let's say 36 here [00:04:01] so 85 will go up 96 come down 85 right child becomes the left child of a or 96 okay so what [00:04:10] are the three steps that is being performed 85 goes up 96 becomes 85 right child and third thing is [00:04:33] the right child of 85 become the left child of 96 right child of 85 becomes left child of 96. [00:04:55] Okay, so this already we have done then in the you can see in a mirror image fashion there is [00:05:01] another thing that is called rr rotation where we are trying to insert on the right of right sub tree [00:05:07] on the right of right sub tree. So what will basically happen? So now here the a and b node [00:05:14] will be opposite. Earlier in ll rotation the b node was the left child but in rr rotation the [00:05:20] b node become the right child and in this case also b goes up and a become the left child of b [00:05:27] and left child of b become the right child of a so three step again there will be okay or just [00:05:37] summarizing in a slide and then we will see the deletion or what type of rotation that are being [00:05:44] perform while doing the deletion okay so just giving you a ll rotation trick or [00:05:59] what actually we are performing so ll rotation if insertion is happening on the left of [00:06:22] left subtree. Then second step is designate the first node from point of insertion, [00:06:54] first node from the point of insertion, which is violating AVL tree property against him, [00:07:18] that is a balance factor property as A. So, who is node A? So, node A is nothing but the first [00:07:27] node from the point of the insertion, which is violating the AVL tree or that balance factor [00:07:32] property. So, we have to designate that node as A. Then the left child, child of A will be [00:07:51] marked as B. Then what will happen? Make B as parent of A and A becomes [00:08:19] right child of B. Further, the right child of A, if they exist, if any, if any, right child of A, [00:08:49] if any, will become left child of E. So, this is the simple instruction you can remember. [00:09:03] So LL, when we are inserting on the left of left subtree, then we will perform LL rotation. [00:09:10] So we have to designate the first node from the point of the insertion who is violating the [00:09:15] balance factor as A, its left child as B, perform the rotation. Okay, B goes up, A comes down, [00:09:23] B's right child becomes the A's left child. Okay, and that's done. Similarly, if you perform [00:09:32] the RR rotation, so when the insertion was happen in the right of right subtree, so designate [00:09:38] a node from point of insertion as A which violates the AVL tree property, then the left [00:09:51] child of A, the right child of A will be marked as B if you talk about RR rotation. [00:10:00] So RR rotation is nothing but mirror image, RR is mirror image of L. So where I have put [00:10:17] A, B other things will be repeated. Okay. So this was the RR when we were inserting [00:10:25] 65 here. So the 44 become the first node, sorry, 34 become the first node that is violating [00:10:32] the AVLT property. So, we designate as A and its right child will be designated as B. Then other [00:10:39] things will be performed accordingly. Okay. So, just remember these three, four steps. So, this [00:10:45] will surely help in doing the LL and RR. Okay. Then the next rotation or I just summarize the [00:10:53] rr rotation if insertion of new node is on the right of right subtree then designate a node [00:11:45] as A, which is first node from point of insertion violating A via free property. Its A's [00:12:23] A's right child will be marked as B rotation, A become left child of B and B's left child [00:13:02] becomes the right child of A. So, this is the summary. Why we are, I am writing this [00:13:11] summary? Because we have to again consider A and B node in deletion or in R0, R minus [00:13:18] 1 and R1 rotation. Okay. So, there this, this what we have summarized will be definitely [00:13:25] helpful. Then we talk about the LR rotation and RL rotation. So, we have also concluded when we [00:13:35] are doing the insertion on the right of left subtree or when we are doing the insertion on [00:13:39] the left of right subtree. So, these are the four possibility we can insert into the left of left, [00:13:45] right of right, left of right or right of left. So, these are the rotations insertion point [00:13:51] we can perform. So, then we also discussed that this LR rotation I am considering is or RL [00:13:59] rotation will have double rotations or LR is nothing but RR followed by LL. So, this means [00:14:07] that if we well understood the concept of RR and LL, so we can perform LR. So, in LR rotation, [00:14:16] rather than identifying A and B, we have to identify three node A, B and C and the point [00:14:24] of insertion is the left of C. Now, the first node that violates the abl tree property here [00:14:40] if you witness is A, but the insertion has happened on the left of right subtree, left [00:14:52] of right subtree. So, sorry, the insertion was happened on the right of left subtree [00:15:03] because this is the left subtree and B and in the B we are inserting it. Okay, so left [00:15:08] of, so right of left subtree, this is left subtree. [00:15:15] Then either there is a direct method, we identify A, B, C, C will become the root, A become [00:15:21] the right child of C and left child of C is the right child of B and right child of C [00:15:28] becomes the left child of A. So, that is the, you can say summary of this LR rotation and [00:15:35] similarly RL rotation is just a mirror image as we have seen LL and RR, okay. [00:15:42] So just giving a summary of this one, LR rotation, when the insertion of new node happens on [00:16:31] the right of left subtree, when insertion is happening on the right of left subtree, [00:16:55] And what we have to do, identify the first node from point of insertion which is violating [00:17:23] balance factor property designate as A. Then C, A, left child becomes P and B, right child [00:17:54] becomes C and if you see basically here A is left child B L L resemblance and B [00:18:09] right child C are our resemblance okay so that is interesting thing you can [00:18:16] of zone and then what we will do fourth position c is parent of b and a that is the now right child [00:18:35] c is left and right [00:18:43] child's are distributed among b and a that is the okay so that becomes the lr notation now [00:18:58] and then in the previous class we have uh do a raw insertion in the uh empty avian tree okay so [00:19:06] So now we will talk about the deletion in the avial tree. [00:19:10] So deletion in the avial tree also violates or also changes the property of the avial tree. [00:19:17] Therefore, we perform three types of rotation that is r minus 1, r 0 and r 1. [00:19:23] So r 0, r 1 and r minus 1. [00:19:26] So what is this r 0, r 1 or r minus 1? [00:19:32] It is the balance factor of the node B. [00:19:36] So, if the balance factor of node B is 0, then we will perform R0. If balance factor of node B [00:19:43] is 1, then we will perform R0. If balance factor of node B is minus 1, then we will perform R0. [00:19:49] So, important thing in this scenario is that the identification of node B. [00:20:00] So, let us start with the R0 rotation, where it is applicable and what else the things. [00:20:06] So, let us say we have a tree A, B. So, B is nothing but the left child of A or we can say [00:20:22] that the first node that is violating the balance factor property become A and its left child is [00:20:34] becoming B. Here we are not considering the right child. Here I am saying only the left child. So, [00:20:40] b so if you see the b b is having now the balance factor of 0 and a is having the balance factor of [00:20:47] 2 because we have removed something from right in the other way what we can say that if we [00:20:54] insert left of left it is as equivalent to deletion from right of right [00:20:59] Okay, so line I will write here, the insertion on LL is equivalent to deletion on RR. Okay, [00:21:25] so just keep in the mind. Now, if you see here, basically here what rotation we are performing, [00:21:31] B is going up, A is coming down and other things. So, this is simple LL rotation. LL [00:21:38] rotation y? So, insertion on the left of left is equivalent to the deletion from right of [00:21:43] right. So, just taking a 2, 3 minute break, then again we will resume. [00:28:57] Now, if you can see, basically what we are doing, we are removing something from right, [00:29:04] then it is as equivalent to insertion on the left. So, here if you see R0 rotation, [00:29:10] So, R0 rotation, R0 means that the 0 is the balance factor of left child of A. [00:29:26] So, A is the first node who is violating the avial tree property. And if the left child of A [00:29:33] that is designated as B is having the balance factor of 0, then what we can do? We can say the [00:29:43] rotation is R0 and this is equivalent to the LL rotation. Because you know LL, so R0 is easy for [00:29:50] So, now if you see an example, if we in this example, okay. So, first calculate the balance [00:29:57] factor 7, leaf node 0, 24, leaf node 0, 60, leaf node 0. Now coming on to the 18, left child 1, [00:30:04] right child 0. So, 1 minus 0, 1. For 20, left child 2, right child 2, balance factor is 2 minus [00:30:12] 2 that is 0, for 24 it is 0 and for 23 it is minus 1 because there is no left child [00:30:20] and only one right child. So, 0 minus 1 minus 1. Now, if you go ahead for 54 it is again [00:30:29] 0 minus 1 minus 1 and for 46 it is plus 1. Now, if we want to remove 60, so now we have [00:30:39] removed it because we know that the BST says first identified the node then deleted. So, [00:30:45] we have deleted 60. Then what will happen? 54 will have balance factor 0 as you can see here. [00:30:53] And this 46 will have become the balance factor of how much? 1, 2, 3 and 1. So, 3 minus 1 that is [00:31:02] plus 2. So, this is the first node from the point of deletion and designate its left child [00:31:08] as B. Now see the balance factor, it is what? 0. So the rotation will be R0 and that is as [00:31:15] equivalent to the LL rotation. And then we do a rotation and afterward if you calculate the [00:31:21] balance factor, so we are witnessing that it is now in the range of 0, 1 or minus 1. [00:31:32] So this is R0 rotation. So R0 is nothing but the balance factor of the left child of the A, [00:31:40] which is the first node that is violating the avial tree property. One important thing here is [00:31:47] A is not always the root node, A is the first node that is violating the property of the avial [00:31:57] tree from the point of insertion or deletion. So, that is important consideration. This root [00:32:02] scenario that every time we are considering A as root is not applicable when your tree is very [00:32:07] large okay this is though we are considering very small example let's say we want to remove 24 okay [00:32:17] let's say we want to remove 24 in it so what will happen the balance factor of node 20 will not [00:32:27] change because it is 18 17 23 okay and thus there will be no change if we again remove after 24 [00:32:40] reboot 23. So, what will happen? Balance factor of 20 becomes 2. 2 minus 0 that is 2. But [00:32:48] here the left child B is having a balance factor of what? 1. So, here the rotation that [00:32:53] will be performed that will be R1. So, that we will consider. One important note I will [00:32:59] write here that a is not always the root node it can be any intermediate node which is violating [00:33:50] AVL tree property which is violating the AVL tree property. Now coming on to the R1. R1 means that [00:34:06] against the balance factor of the node B is 1 rather than 0. So, if we remove something from [00:34:16] here, so A becomes the node that is having the balance factor 2 and B is the node that is having [00:34:21] balance factor of 1. So, we will now perform R1 rotation. And if you see here, what is happening? [00:34:34] B is going up, A is coming down. So, again, this is a resemblance of LL rotation. Again, [00:34:40] it is a resemblance. And why we are calling R1? Because the balance factor of the left child of [00:34:47] the node A is 1. So, simple. So, you need not to panic. Just if you remember LL rotation applied, [00:34:53] you will get back the result. So here, if we want to remove 39, so what will happen? 37 will have a [00:35:03] balance factor of what? 2. Then what will happen? 26 will go up, 36, 37 comes down [00:35:13] and right child of 26 become the left child of 37. So here is the rotation tree. So basically, [00:35:22] this is LL. Why we called R1? Because the balance factor of node B is 1. If it is 0, then we will [00:35:29] call it as R0. So, I hope deletion is clear because it is simply you can say a variant of [00:35:36] LL rotation. Now, coming on to the last rotation that we perform that is R minus 1. So, of course, [00:35:45] the node B will have the balance factor of minus. So, this rotation is as equivalent to [00:36:00] LR that we have studied. So, here the balance factor of node B is minus 1 if you can see [00:36:08] and A is now 2. So, we have to identify the another node C that is right side of B [00:36:17] and then perform the LR rotation, simple LR rotation what we have did [00:36:21] and we will get back our result. So, here is the thing when we want to remove 52. [00:36:31] So, what will happen? The balance factor of this one is minus 1. So, this is A that is violating [00:36:39] B and C. C goes up, A comes down and left child of T become the right child of B and right child [00:36:54] of C become the left child of A, that is the rotation. So, in summary, if you write, before [00:36:59] starting the new tree, in summary, what I can write R0 is equivalent to LL, where node B is [00:37:17] having a balance factor of 0. R1 is also equivalent to LL, where node B is having a balance factor of [00:37:29] 1 and R minus 1 is equivalent to LR where node B is having the balance factor of minus 1. So, [00:37:37] this you have to remember. So, deletion becomes very easy because we already had a function or [00:37:43] we already know how LL rotation and LR rotations are being performed. Now, [00:37:49] Now, if I ask a question, why sir, you are always constructing a tree that is having [00:38:01] only two child? Why not we can construct a tree that is having more than two child? So, [00:38:09] the question is, yes, we can have such kind of tree. So, in this part we will target trees [00:38:20] that is basically called as M-Way rather than two-way tree. So, two-way tree is binary tree [00:38:26] and other than it is called as the M-Way tree. Now, let me talk about the practicality where [00:38:43] this M-Way tree or its variants. So, in this part, we will cover two important trees that is [00:38:49] M-Way tree and M-Way tree and to balance M-Way tree, there is another tree that is called as the [00:39:00] B tree and there is one more variant of B tree that is called as the B plus tree. [00:39:05] So, there is a light difference between these two, but this is the balance M way tree. [00:39:13] So now, let us talk about one important concept. [00:39:19] In secondary storage, primarily when we consider the hard disk, in secondary storage, what [00:39:31] basically we are doing we are adopting the mechanism of indexing or we can say even sometime [00:39:39] we have multi level indexing and for because this this batch is full of diverse background people [00:39:48] so what i can say that if i have to search for a specific topic in your book then what i will do i [00:39:54] will first go to the index page and search okay the chapter number four is having this topic at [00:40:02] this page number then we will directly go to that page number and fetch the data okay if let's say [00:40:07] this index space was not there in the book then what we will do we will search entire book and [00:40:12] identify a specific topic when a very large time so this this basically what is happening [00:40:19] with indexing thing we can get direct access to the data or frequent access to the data or in [00:40:26] other term we can say that the the search or traversal search time is easy because when we [00:40:35] ask some question and if its result is coming in a longer duration then no one is going to use our [00:40:40] website or web browser so it should be limited so therefore if we do this indexing similarly if this [00:40:47] index is very large as well okay so we can have another index that is having only the information [00:40:54] about the chapters. And inside the chapter, it is having the detailed information about [00:40:58] what are the topic covered and what are the page number. Similarly, we can do another [00:41:03] label. So, what this is, this is called as the multi-label indexing. So, the data that [00:41:11] is being stored in the secondary storage can be referred from a index, okay, and which [00:41:18] can be further referred from another index, okay. So, suppose if I want to search something, [00:41:22] then what we will do? We will first refer to the first label index, second, third, fourth, [00:41:27] fifth and last label, we will find our data. So, this is how, so when we store data in the [00:41:34] hard disk in form of sectors, blocks, so what we will do? We will also maintain one index, [00:41:44] which could be multi-label, which could be multi-label, further index, index, index and [00:41:50] so on, so that the retrieval can be easy. Now, what is the situation? We have to [00:41:57] maintain multiple value on different labels. So, we cannot say that a single element likewise in [00:42:07] binary search tree could be stored to facilitate it. So, for this we have to make a node that is [00:42:14] having m child rather than two child. m could be 5, could be 7, could be 3, could be 4, could be 2, [00:42:20] whatever we want will be the m number of child will be there. So now how to control what type [00:42:31] of information are being stored. So now a node will look like this one. We are having multiple [00:42:36] values and multiple child information. So this type of tree is called as the mv tree. So how [00:42:43] mv tree is formed, how that values are stored and how other deletion and insertion happen that we [00:42:50] will see in detail. One more thing now I hope mv tree is the tree that is having the possibility [00:42:56] of m child and each node will hold not a single value like BST but could be a set of element or [00:43:03] array or even you can say entire index thing can be stored in a single node. So before studying [00:43:16] the property or what is the thing? Let us say I had two nodes, 17, 16 and 21. So, this [00:43:51] is also BST, this is also BST, binary search tree, binary search tree. Now, what I did, [00:44:00] I merged them or even let us say I have another binary search tree, 22, 23, 21 and 27. So, [00:44:18] these are binary search tree. I hope everyone will agree because it is following the property [00:44:22] that is left less than right root which is further less than right. So, all three are BST. [00:44:32] Now, do one thing. So, this is totally off the topic means I do not claim this is part of book [00:44:40] but to let you know how mv tree looks like. So, there this will help. Now, I want merging. [00:44:52] i want merging all stuff so what will happen 13 left child no worries [00:45:01] then i merge with 17 and here is one will be pointer that will hold two values that is [00:45:08] 15 and 16. similarly we have 23 where two values will be stored that is 21 and [00:45:16] let it let it be 22 because we know that binary tree don't allow duplicate element and here we [00:45:25] have 27 okay so what this means now this tree is not two way it is two way means two now the [00:45:34] childs are one two three and four four child so this is a four-way tree where maximum allowed [00:45:42] child could be four and the number of element maximum number of element that could reside on [00:45:48] any node will be three okay and here order is what increasing order 13 17 23 and if you see [00:45:56] here one interesting thing this 7 is less than 13 and in between node is what in between is in [00:46:02] between so it it should be greater than 13 and less than 17 15 and 16 here the nodes are 17 23 [00:46:09] So, greater than 17 and less than 23 and here the greater than 23 is stored. So, [00:46:17] basically mv tree is nothing, you can assume it is a merger where the common point hold the [00:46:24] property of BHT where root is less than those value on the left side and root on the right [00:46:30] side will be greater than that one. So, this is how we are forming a mv tree. So, let us consider some [00:46:39] property and example okay then we will take the query now [00:47:25] so mv search tree all the data structure discussed so far like bst and other uh in the [00:47:32] internal memory stored in the internal memory hence support internal information retrieval okay [00:47:38] so bst and other things are primarily using the rant to favor the retrieval and manipulation of [00:47:45] the data stream into the external memory via storing device such as hard disk it is required [00:47:51] to have some specialized data structure as i was discussing okay just give me a minute just give me [00:48:08] one minute okay so mway tree so mway search tree b tree b plus tree are example of such data [00:50:14] structure that allowed different retrieval pattern for the secondary storage. And here of course, [00:50:21] the height of the tree is close to the log of n. So of course, the search and other things will be [00:50:29] accordingly managed. So now let me take your queries, then we will see one example and how [00:50:49] this property are maintained in that we will check it out okay so uh ohm you can start [00:51:04] providing access to one by one on for anuja i am doing others you can see [00:51:10] okay sir yes good morning sir good morning uh sir if you can go to the deletion slide [00:51:20] very well explaining uh which deletion r0 r1 any one thing yes we can do with r0 also [00:51:32] that is going to find uh so the example that you were giving right uh the numbers uh yeah yeah so [00:51:39] here uh does this 60 when you said delete 60 is it going to be provided in the question uh that is [00:51:47] it will be provided okay and in the real time scenario when uh when this has been implemented [00:51:53] I mean, in terms of the RAM, right, it is being used, you said. [00:51:57] So here, I mean, the question was how this deletion part that is 60 is being deleted [00:52:03] or 60 is a position where we need to do the rotation is supposed to be taken up [00:52:09] as a part of implementation I'm trying to understand. [00:52:12] I mean, I know the lab will be going to explain it, but as a theoretical concept, [00:52:18] how this 60 is being chooses so that the thought process can be cleared. [00:52:23] there is a no so so 60 could be one some record some specific record okay which we want to remove [00:52:31] from our this okay so maybe this 46 is a um you can say index stuff or uh or this 60 is an index [00:52:39] and stuff that we want to simply remove okay so that is now target is given so if we remove [00:52:45] because we are making a logical structure of the tree like structure and if 60 removes then [00:52:50] our logic will fail because the access time will will increase because we are having left branch [00:52:58] more longer than right branch so to balance out those things we have to perform so again i'm [00:53:04] saying this avl bst other things are the logical organization of the memory and we try to keep the [00:53:10] balance factor 0 1 or minus 1 so that the log of n search time will be maintained okay so if i just [00:53:18] say as a understanding the the kind of property which we are going to use here is uh just because [00:53:25] we are trying to balance the indexing part is it sir yeah left height and right of the height of [00:53:31] the tree or primarily it is so 46 20 54 could be the index or uh location of some of the data that [00:53:39] we want to fetch okay let's say i want to delete some data that is stored at some location y [00:53:43] and that is pointed by this 60 so simply removal of the 60 indicate what there will be no pointer [00:53:49] to the data and automatically the data will be removed sure so sir just to extend this question [00:53:56] so uh i mean in a implementation or in a user's point of view uh if i say any application which [00:54:03] is being uh utilizing the ram as a as a primary storage when it's loading so like any any model [00:54:11] is being loaded is being loaded in the ram at the first place yeah when it actually has a kind of [00:54:15] environment which is a cpu kind of environment does the cpu shares the processing area and the [00:54:22] ram shares the actual storage part right there right there does this uh indexing process when [00:54:29] we say this right uh like deletion as well as the insertion position is being logically applicable [00:54:36] there too if we just say because uh that modeling will also be happening over there as a part of [00:54:42] yes yes yes as a part of ram to utilize the space or to ensure that the faster access [00:54:48] these policies are already there and beyond this we will see b plus three that is already there in [00:54:54] modern hard disk as well b plus okay our b plus in also using uh this dv dvms very very highly [00:55:02] that are used for faster access okay and does this also extend with the vram processor uh yeah yes [00:55:10] yes yes so the what the concept of vram is also coming so the because it is also the part of hard [00:55:15] disk so this logical arrangements uh help so if these kind of things were not there so we never [00:55:20] able to get the vram thing in our pc yes absolutely so i'm just summarizing the part of vram also [00:55:27] so does this vram covers the m-way assembled with this uh logical structure of the ram which we just [00:55:34] talked about yes yes okay so it's an ensemble approach okay yes yes to provide the extra [00:55:40] space we are now creating one logical arrangement so that we can get more ram in our memory okay so [00:55:47] it's a combined process where combined process and and those data that are less so kind of cast [00:55:54] and so if let's say some data that need to be loaded in a while or we can say that that that [00:56:01] immediate requirement is not there so we will push toward the vram and then it is pulled toward the [00:56:06] ram so sir one more question so does the caching also follows the same approach here i mean uh [00:56:13] because caching happens in the real time movement only and uh uh i just take an example like we do [00:56:20] currently the llm caching right we just don't go with the inference directly at times we go [00:56:25] with the caching approach too so the inference can be faster faster so so does that also follows [00:56:32] the same uh concept of this uh you can say so caching and the the logical organization and [00:56:39] other stuff of course there is but but it is managed by uh different other properties so it [00:56:44] is primarily aligning with the scheduling and other stuff so rather than going toward the tree [00:56:48] another structure so this is how the faster access to of the data is stored in the secondary devices [00:56:54] and caching is the key what are the frequency of the data that we are witnessing so the two [00:56:59] different things but if i found some tree that are primarily emphasizing on the [00:57:04] cache logical organization then i will discuss in class someday okay in some day okay okay [00:57:09] sir thank you so much sir thank you so much hello sir good morning good morning hi sir i have a [00:57:33] question like um how does the avl tree's height constraint mathematically guarantees a complexity [00:57:39] of o log n search time where we can derive the minimum number of nodes required for the tree [00:57:45] for the height in so um uh if you see uh if you see when we have started avl and we were talking [00:57:53] about the skewness if a bht that is totally in the leftward direction okay so it become a linear [00:58:00] search for identifying any element so avl say that whenever a new insertion or deletion will happen [00:58:06] i will try to restore the height in the range of 0 1 or minus 1 means that the left tree is [00:58:13] having a difference of either 0 1 or minus 1 so that is allowed okay so in that way when you want [00:58:19] to search something so you will not reach to order of and it will be somewhere order of n or n plus [00:58:24] one or n plus two so that that that is strategy that this basically avl tree is adopting by by [00:58:30] using the balance factor thing okay okay thank you sir i guess ohm we are good to go no more [00:58:50] hand raised okay thank you thank you so either i am teaching very good or people are not getting [00:58:57] the concept okay but these topics are little little tricky uh that i assume because those people [00:59:07] who are seeing first time. So, of course, that is difficult. So, just go through my PTs and this, [00:59:13] you can say video lectures. So, definitely that will be helpful. Now, starting the m way tree. [00:59:28] So, I am just closing this. I had new slides. Now, before reading the property, let us see [00:59:44] one example. So, here we have five way tree. So, five way tree means the maximum allowed child is [00:59:52] 5. So, minimum is always 2. Maximum, so if any tree is given and this 5 way, 6 way or 3 way is [01:00:02] not given, so identify any node that is having the maximum child. So, here what is here? 1, 2, [01:00:08] 3, 4, 5. Here there is another node that is 1, 2, 3, 4, 5. This means that this tree is a 5 way. [01:00:14] So, if no information is provided, then what we can say? We can identify any node that is having [01:00:20] the maximum number of child and if what is the number will be the way of the tree. So, this tree [01:00:25] is a 5 way means that maximum allowed child is 5. Now, on each node we have two fields. One is [01:00:31] address pointer and another one is the key field and we know that addresses could be 5 because it [01:00:38] is 5 way. So, key could be 4. So, there is a relation that key equal to m minus 1 and address [01:00:47] equal to m that is the m way tree okay and second thing is that in all the node key are arranged in [01:00:54] ascending order if you see here okay now one can see why some some nodes are having less tree why [01:01:00] some nodes are having so this this is a resultant tree after performing multiple insertion and [01:01:05] deletion okay and when we draw a tree from very much scratch so we will try to fill all the nodes [01:01:12] on one level then we will go down okay so that the formation will be different but here this tree is [01:01:19] arising from multiple insertion and deletion so we are seeing this kind of structure [01:01:23] so maximum allowed child is five minimum allowed child is two so if you see here [01:01:28] 262 is a node that is having two child so this is equivalent to bs3 okay this is having three [01:01:34] three key four child this is having one key two child this is having two key three child so [01:01:39] So, child could vary from 2 to 5 and key could vary from 1 to 4 and all the keys are arranged [01:01:46] in ascending order. [01:01:48] Okay, second thing is that if you see here, the left is having the child that are less [01:01:54] than 18, there is no right child, here there is no left and right child. [01:02:00] If you foresee 198, the left child are less than 198 and greater than 76 and right child [01:02:06] are greater than 198. [01:02:08] this property that we have to maintain okay so what we can say I hope you people are clear so [01:02:20] key could be 1 2 3 4 addresses could be 1 2 3 4 5 okay and node can have 5 2 2 2 5 child he will [01:02:29] be 1 2 4 okay so let us check out the properties then we will see the how insertion deletion and [01:02:37] other steps are being performed. Now, the M way tree may be an empty tree, T is not empty, [01:03:00] maybe empty means that there is no key and no address or child pointer. So that will [01:03:09] be an empty tree because nothing will be an empty tree of course that we know. Second [01:03:14] thing if it is not empty then what are the property? So for some integer m known as order [01:03:20] of the tree each node is of degree which can reach a maximum of n degree means that maximum [01:03:26] number of child could be five in other word each node has at least at most m child node [01:03:33] that most means that maximum node will be max will be m a node may be represented as a 0 [01:03:42] k1a1 k2a2 k-1 a-1 where ki are the keys and a0 are the pointer to the subtree so that we know [01:03:54] if a node has k child node where k is less than or equal to m then the node can have k-1 key [01:04:05] getting if it is having k child node or five child node so maximum key could be what four [01:04:10] second thing is that contain the node is such that k of i th node is less than k of i plus 1 [01:04:19] that we know with that ascending order ascending third if node a 0 k 1 a 1 k 2 a 2 all the key [01:04:29] value in the subtree pointed by a of i is less than k plus 1 okay and all the key in the subtree [01:04:38] pointed by a m minus 1 are greater than a m minus 1. So that is the same property if the tree being [01:04:45] pointed by 18 in the left is less than 18 in the right greater than 18 but less than 44. That is [01:04:53] just remember this the merger what we have told okay. BST two trees were there then another two [01:05:02] trees were there. So while merging what we will do we will insert here here and middle one will [01:05:06] have the values that is greater than this but less than this. So, this property is node. [01:05:14] So all values in the subtree pointed by a i, a i is here if you can see, is less than [01:05:21] key k i plus 1. And for each node a i 0 to i minus 1 also known as m-way search tree. [01:05:29] So key will be m minus 1, okay. [01:05:33] So if you see here, this is the 5-way search tree. [01:05:37] I hope you people can connect what I am saying. [01:05:41] On each node maximum allowed key is m minus 1, maximum allowed child is m, minimum allowed [01:05:47] child is 2, minimum allowed key is 1 and extreme ends for left and right, there is no worries. [01:05:54] But for what we can say the common end. [01:05:58] So, the range of value that is being stored on the address A1 is in between 18 and 44. [01:06:05] On address A2 should be in between 44 and 76. [01:06:09] On A3, the address that is stored value will be in between 76 and 198. [01:06:16] So, if you see here, it is following. [01:06:19] So, all the values, even 186 others are less than 198. [01:06:26] And here on the extreme is, we have to put the higher factor, okay. [01:06:31] So I hope the property of mbit is little bit clear to you all, okay. [01:06:38] And now talking about the searching thing. [01:06:44] So searching, because we know that all the keys are stored on the, each node are in ascending [01:06:56] order. [01:06:57] So let us say we want to search something. [01:07:01] we will directly get a part from any node or maximum number of comparison that we have to [01:07:06] perform on each node will be the m minus 1. And that is much, much less than that of the [01:07:12] total number of node in the tree. And therefore, the searching time will be again tends towards [01:07:21] log of n. Now, one question arises, sir, on each node we are having number of keys. [01:07:26] So, how the searching time is log of n, because on each node, of course, I am agreeing that [01:07:32] it is having number of node, but that is far less than that of the total node in the tree. [01:07:40] So searching is easy, we can start with the root as we were doing in the binary search [01:07:44] tree, fetch out the element in the root and accordingly we will get a direction key where [01:07:49] we have to move. [01:07:50] Let us say we want to search 186. [01:07:53] on this node 80 44 76 and what is the value 186 so it will be in between 76 and 90 so here we get [01:08:03] an address so we reach here so what we found 144 greater value so 186 and here we identified 186 so [01:08:11] searching in m-way trees as similar as BST but on each node we have to do a [01:08:20] searching of maximum of m minus 1 maximum of m minus 1 so searching is in [01:08:31] this way insertion and deletion aspects is a little bit tricky okay so in any [01:08:41] Any tree that I have discussed before in binary search tree or in AVL tree, similarly in MVA [01:08:46] tree. [01:08:47] So MVA tree you can say is an extended variant of binary search tree. [01:08:51] There will be no duplicate element. [01:08:53] So before inserting a new node, we have to first search whether it is available or not. [01:08:57] If it is not available, then we will add otherwise we will deny. [01:09:02] So now I want to insert something here. [01:09:07] I want to insert 6 in this node. [01:09:13] this tree if I want to insert 6, so 18 says 6 could be placed on my left, here we go. [01:09:20] So this say 6 could be placed on my left because 7 is the value. So what we will do? We will [01:09:27] insert 6 because we know that each node can have the key count of 4 and here the key count [01:09:37] is only two so six can be directly injected or inserted okay now if i want to insert 146 in [01:09:46] this tree okay so insertion and deletion i will cover in detail in the next class okay okay so [01:10:26] insertion can be happen on a node up till we have sufficient space and there is no downwards key if [01:10:35] let's say there was some downward key from the seven so we will first explore that path if we [01:10:39] don't find then we will add 6 there. Since 7 is not having any left child, so 6 was inserted here. [01:10:46] So this all discussion of insertion and deletion we will cover in the next class. Then we will see [01:10:53] one of the interesting and famous tree that is called as the B tree and afterward there is the [01:10:57] last topic in the tree that we will cover that will be the heap. Then we will start the graph [01:11:03] little bit and afterward dynamic programming and other aspect we will try to cover. [01:11:08] okay so i am stopping here for today because insertion will require another thing and i [01:11:14] have already covered some complex things so just requesting after this class i will upload the [01:11:19] ppt do refer it okay and in lab we will try to also cover the mv3 insertion and deletion okay [01:11:30] so at least insertion i will ask my tier to cover in the upcoming lab okay i am stopping here [01:11:38] and if someone has any query then then will it happen to be yes uh anuja your mic is already [01:11:45] enabled yes sir if you can go to the slide again uh where you explaining the example of five way [01:11:51] tree actually kind of lost how the tree is structured okay let me draw a bare hand okay [01:11:59] so the so the one question has started it's this 1844 76 198 no no so this is the five way tree [01:12:08] so it was 18. so is it a merge tree already sir so like uh it has some bsts which has merged to [01:12:17] 18. yes yes why i am feeling that now there is no such kind of concept in any literature but you can [01:12:23] visualize how the things are happening so that's yeah that's where yeah yeah so how it has been [01:12:29] started from there i'm just kind of lost actually yeah how empty tree is formed like this yes yes [01:12:35] yeah so uh basically um let's say i have some set of values okay i'm just putting 17 17 okay so so [01:12:48] this is good for everyone 17 32 45 73 29 44 48 47 41 unique value because they do not allow [01:13:02] duplicate it now i want i say that form a three-way tree so the tree that you people have [01:13:10] witnessed is the tree that is resultant after multiple insertion and deletion okay and when [01:13:14] we try to draw a tree that will not look like that so three-way first node is 17 second second [01:13:21] node is 32 that is formed and there will be three pointer one two and three now 45 comes so it will [01:13:29] go in the this directions then come 73 so it will be accumulated with here because maximum allowed [01:13:37] node is maximum loud um keys are two so one one question here uh so when you selected 17 and 32 [01:13:44] does it anyhow have to have a sorting firstly so first 17 17 is added if let's say first node was [01:13:51] 32 then 17 so we will insert it and sort it because 29 is already there in the list [01:13:57] but but first note that we encountered is 17 so we are not okay okay okay okay okay then then 29 [01:14:06] comes so it will be placed here then comes 44 so 44 will try to accommodate but it say i am full [01:14:14] so you can be my left child then 48 comes so it is saying 45 is saying what you could be on my [01:14:21] right so it is 48 then 47 comes so 47 says 45 says you can go to my right 73 say you can go to my [01:14:32] left so 47 is added here so here what we are having 48 but 47 is inserted just before then [01:14:39] comes 41 so 41 will be inserted here so this is the tree how it will look like other value will [01:14:46] come so so we will try to fill in one label then we change the label so that a compact structure [01:14:51] is formed okay so it's like uh firstly we go ahead with this uh uh routing point which is like 17 [01:15:00] and then then we will put 32 now that label is full so we will come down to another level [01:15:08] so i mean so just to confirm so when we selected this 29 29 is selected uh via the [01:15:15] logical answer that this is lesser than 32 uh that has to come with the left yeah and higher than 17 [01:15:22] is it sir yeah yes yes that is the okay and the same with then 32 is like uh showing across the [01:15:29] right so it's like giving 45 but again it's a higher number uh it's from 32 it's not the lesser [01:15:37] one yeah yeah uh so sir how it is being just to confirm because 17 yeah i understand 29 is higher [01:15:45] than 17 but uh 7 but 32 which is like the 40 45 45 is higher than we are doing insertion from the [01:15:53] beginning now so first i encountered put it to the root second element i encountered put it into the [01:15:57] root because space was there now root is freezed then 45 comes so it will go beyond 32 or in the [01:16:04] the right of 32 so 45 comes here okay okay okay okay in that way okay okay understood sir okay [01:16:13] yes mohit good morning sir good morning yes doubt is in the same example what you have explained [01:16:29] just now yeah so you have taken two notes 17 and 32 because we are having two places here [01:16:37] or just two will come i mean how we decided i have i have considered about three way trena so [01:16:42] maximum key could be two maximum child could be three okay thank you thank you okay so we are good [01:16:54] to close thank you everyone for joining and tomorrow the class will be important because [01:16:57] i will try to start b plus b tree so that is important concept so do join okay thank you [01:17:04] thank you everyone thank you thank you sir thank you thank you sir bye thank you for your support