[00:00:14] So, in the yesterday's class, we have started an important tree of DB that is B-tree and B-tree is basically the balance variant of balance M-way tree. [00:00:37] We have witnessed that M-way tree was offering the multiple path axis, but it may also face the problem of left skewness or right skewness. [00:00:46] So, therefore, to mitigate those problems, B tree was introduced. [00:00:52] And there were some properties in the B tree. [00:00:54] first it says that the root node the root node can have 2 to m child internal node internal node [00:01:17] can have m by 2 to m child so there should not be any violation and third important property other [00:01:27] properties are as similar as M-way tree, all the leaf should be at, all the leaf should be [00:01:36] at same level. So, these were the some properties that were different from that of M-way tree. So, [00:01:47] by ensuring all the leaf at same level or ensuring this internal load root M by 2, sorry, [00:01:55] ceiling m by 2 to m this b tree ensures the height in the left and right direction are [00:02:02] comparable and in this way the our target of achieving log of n computational complexity [00:02:08] for searching insertion will remain intact okay so we have started and seen these properties [00:02:16] there is a fourth third property as well so number of key in each internal load is one [00:02:20] less than that already we have witnessed in MV3. Now then we have started a discussion on the [00:02:30] insertion. So whenever there will be an insertion we will first try to search it. So first we will [00:02:39] search. If search is unsuccessful means that the element is not found then what we will do? We will [00:02:45] try to accommodate the node where we are right now or where we have declared that the particular [00:02:51] element is not available so there might be two condition if that node is empty empty means that [00:02:57] there is some space where we can accommodate so add it add it in ascending order okay so whatever [00:03:07] the suitable place we will add it if it is full then what we will do then the scenario is add the [00:03:21] new element in a specific order now we have added the new element in the specific order then [00:03:34] then what we will do then pop up the median element and place it into [00:03:50] upper node okay upper node what we will do we will add the node and pop up the median element [00:04:02] and when median element will be proper of course we will got two node in place of one node okay and [00:04:08] both the nodes will be left and right child of that specific node and the pop-up one one will [00:04:13] add into the upper node okay and the pop-up one will be added into the upper node to a specific [00:04:18] place. Childs are defined just we have to insert it. So, this was a 5 order tree and we have to [00:04:30] add let us say 4 in this. So, 4 will first go to this node, 8 say yes, you can accommodate on my [00:04:37] left now it go 4 go here. So, these nodes say there is no further node downwards. [00:04:42] So, we can accommodate you on this label. So, 4 will be added at its specific place. [00:04:48] Similarly, for 5, 5 will be added because there was a space and this is 5 battery, [00:04:53] so 4 key could be accommodated on each node. 4 keys can be accommodated on each node. Now, [00:05:01] when we want to insert 58 in this scenario, in this we want to add 58, then what will happen? [00:05:12] So, 58 first go to 8, 8 say you can go to, you can be accommodated on my right, but 96 say you [00:05:18] can be accommodated on my left then it start exploring the downward path what it identified [00:05:23] 37 46 55 86 55 and 88 not 86 88 now 50 it will come here so it will be probably accommodated here [00:05:41] but when we accommodate 58 here then what will happen then this node will have [00:05:46] the key more than the allowed one. So, what will happen? The median will be what? 55. [00:05:54] For median, the formula can be n by 2 plus 1 or n by 2. So, this is for odd and this is for even. [00:06:05] Okay. Now, 55 will go up and 2 child that will be 36 and 37 and 46 and 58 and 88 will be formed [00:06:14] and it will be added to its appropriate location. So, appropriate location is what? Before, [00:06:19] after 8 and before 96. So, after 8 and before 96, a new node was introduced with two child, [00:06:26] one is 36 and 46 and another child is 58 and 86 is introduced. Okay. Now, someone says I will [00:06:35] do one more level up. Okay. So, what it is? So, we are inserting 6 in this tree. Insert 6 in this [00:06:45] three six go to eight eight say there are nodes on my left and you are since you are less than me [00:06:51] then you could be accommodated here so it will go to this node so these nodes says two four six [00:06:57] you could be placed on in after five you could be placed after five but we are having the maximum [00:07:07] node we are having the maximum node so what we will do we will pop up five to the above node so [00:07:13] what will happen? 2 child 2, 4 and another child 6, 7 will be formed with a 5 node pop [00:07:21] up. But when a 5 arrives here, then what will happen? 5, 8, 55, everything will be added. [00:07:28] But this node again will have more than the maximum keys. So, if 5 added here, so 55 will [00:07:38] be pop up and when 55 pop up then we will have 2 child 5 and 8 on this side and 96 and 116 on the [00:07:48] another side okay and remaining things will be likewise okay so what we can witness from here [00:08:00] we are witnessing that rather than what the trees we have covered so far after insertion they were [00:08:05] growing downwards, this B tree is growing like an actual tree and it is growing upwards. [00:08:13] So, I hope this insertion is clear. If there is a place, simple thing, if we want to insert [00:08:38] new node first search it. If not found, then we have to insert. If not found, then we have to [00:09:06] insert. And all the two cases if you have, so the insertion is done after searching. [00:09:24] okay and deletion in b tree is a little bit tricky so i will start after one more example [00:09:40] then just keep your seat for patiently for half an hour i will cover the things then i will take [00:09:50] up the queries okay and this insertion i am just finishing so let us consider another tree [00:09:57] that is of order 3, that is of order 3. And in this we want to do certain insertion. So, [00:10:07] when we are saying order 3, so child, maximum child will be what? 3 and minimum will be 2, [00:10:17] because 3 by 2, chilling will be 2 and keys will be 2, 1 less than the number of child is 3 minus [00:10:30] one so this we have to keep up now this is a order three three so maximum child could be three now [00:10:54] we have to insert 75 so first it go to 50 50 says there are entries on my right you can check it out [00:11:06] now it arrived here so 60 says i can accommodate you but there are entries on my right [00:11:13] and it seems you are on my right so it will go here not 65 70 and 75 will be there so these nodes [00:11:20] declare that we are not there in the tree but if we accommodate you here then i will violate the [00:11:28] property because number of key will become three so what will happen so the median element that is [00:11:36] and plus one will pop up and go in the above node and we will form two child that we will form a [00:11:42] structure like 70 one child is 65 and another child is 25 and this 70 will be accompanying with [00:11:51] 60. Now we are inserting 57. So 57, 50 says you could be placed on my right then 60 and 70 say [00:12:02] you could be placed on my left so now 57 arrives here then what will happen this will again start [00:12:13] violating the order 3 b3 property because the maximum allowed key was 2. Now 55 57 and 58 so [00:12:26] which one is median 57 so 57 will pop up and goes here and we will have a node 57 with two child 55 [00:12:36] and 58. Now what will happen? Then 57 arrives here, then this node is again full. So the [00:12:58] median element that is 60 will go up. So if you see here 50, 60, 57 is now added here and 70 is [00:13:10] added here. So that thing is, this will pop up, then median element will pop up. So this is called [00:13:17] as the cascade cascading operation we were inserting 57 but it let down the disturbance [00:13:30] in the tree at two hierarchical level it it can go even more okay when your tree is let's say very [00:13:36] long so it will even go more so i hope insertion is clear so even if anyone has any doubt in [00:13:46] insertion let us take then we will start deletion no sir currently there is no hand okay one need [00:13:52] this okay it is you can go first hi sir good morning good morning so for insertion of 75 [00:14:07] as we insert 75 in the first step we see 65 70 are together and when we try to insert 75 [00:14:15] we have to send 70 up due to the rule violation and then we separate [00:14:19] 65 and 75 so why did we separate 65 and 75 we could have kept them together right [00:14:27] no no so uh when we are inserting a [00:14:31] uh new node so 65 70 75 so this is the policy key when a node will be pop up so these two will be [00:14:40] splitted at its left child and right side okay okay yes okay got it got it sorry you can go next [00:14:55] very good morning sir good morning sir actually i have a question uh it is like the doubt is [00:15:02] regarding that conceptual uh thing about the data structure i just want to ask like uh we have [00:15:08] binary tree and like b plus b3 right both have like time complexity of order of login so my [00:15:16] question is that why do we practically need b3 because in this case we are neither like the [00:15:22] complexity is not uh improving in terms of b3 to be sorry from binarity to b3 then what's the need [00:15:29] of like b3 okay so actually when we are following uh this multi-label hashing okay so in which we [00:15:41] know we are storing the addresses of uh let me open it so basically what will happen when we [00:15:59] talk about the multi-level hashing okay so what basically we are doing we have these many number [00:16:11] of um information stored okay let's say one two three four till 1024 and let's say this information [00:16:20] so what we will do when we try to directly access so what we will do we will start from this location [00:16:26] and keep on searching. So order of let us say it is very long. So your response time will be [00:16:32] accordingly very large. So what basically we did? We made a index. So that say I will store the [00:16:42] value in chunks of 100. So whenever we want to search we go to a specific chunk and it provides [00:16:51] the 100 addresses where we have to search. So searching time is reduced. Now we have another [00:16:56] label of hashing that say i will store 10 10 addresses of this hash table only so when i [00:17:02] request comes so it will just search uh uh in the 10 specific addresses and accordingly it will go [00:17:11] outside so what basically we are doing on each label if you witness there are not single node [00:17:16] they are not single node they are having multiple entries so if you resemble the bst binary search [00:17:23] tree so that we are having a single entity and here we are having multiple entities so this is [00:17:28] basically the structure of b tree and in case of binary search tree when we have to access only to [00:17:35] two part because because if we keep here one uh let's say one node so we cannot do this so for [00:17:41] multi-level uh you can say here are hierarchical arrangement or multi-level access we required this [00:17:47] kind of structure so again i'm saying this bst and b trees uh conceptually they are more or less [00:17:54] similar but where the place where it will be used for multi-label hierarchical arrangement b trees [00:17:59] are used where each node is supposed to have more than one entities as compared to that of binary [00:18:05] search stream okay and binary search trees is specifically used for a you can say very smaller [00:18:10] operation or you can say we have remember one application the duplicate removal [00:18:18] duplicate removal in the ram if we want to remove some some data we have we want to remove something [00:18:23] there bst can be used but when we talk about the data databases or very large values there are [00:18:29] stored then this type of hierarchical things are from and if you remember the tree this b tree okay [00:18:37] it is also looking like a hierarchy and one more additional thing i will tell that b plus tree there [00:18:43] is a famous that is you can say variant of b tree that says that all the data will be pointed by [00:18:49] the leaf only and internal node will hold the pointer to that data okay so uh that are the [00:18:56] things that you you you can again yes so basically yeah that's right like uh you told like if we have [00:19:03] multi-level hierarchy then it is like we are using b tree instead of binary tree so basically [00:19:09] this multi-level hierarchy is introduced just to make the like sort of search uh like searching of [00:19:15] the data and yeah yeah efficient so it's like see uh if we have binary tree or b tree both have like [00:19:23] in terms of time complexity if we see both have like order of log n uh the search timing yeah [00:19:30] so if we if we like uh use a single b tree or multiple binary search it would also come down [00:19:37] to order of log n ultimately the complexity yeah so that is what i am trying to get why [00:19:42] we are not using binary tree in the like second there is no role of binary dreams [00:19:48] so for example if i make multiple binary tree okay so what i have to i have to store the root [00:19:53] node information into the ram okay i make thousand binary binary tree so i have to maintain thousand [00:20:00] informations in your ram and here what i will do i will just store a node information of of this [00:20:06] multi-level hierarchy a single node information into the ram so that's why it when it grow grow [00:20:11] grow grow grow faster now then from this access we can only get the access of entire memory but [00:20:17] if you use binary tree then what will have binary search tree so to just two two two two labels we [00:20:22] are going down down so multi-level hierarchy could not be possible using bst so both three are [00:20:30] existing but their role is different their role of b3 is towards the the secondary storage and bst [00:20:37] towards removal of duplicate element efficient searching and other aspects so that we can [00:20:42] primarily do in the main memory so both are existing that i am not saying even [00:20:47] b3 b3 was introduced bst is vanished so both are still exist so basically i just want to uh i just [00:20:55] want to get this clear line uh what makes this difference like why why would transist from b [00:21:01] binary 2 to b3 that that was like whole of my point so simple 100 bst or 100 binary search tree [00:21:10] can accommodate if i just talk about a single label can accommodate let's say [00:21:19] 2000 addresses and a single pst with multi-label hierarchy okay can so let's say in your ram there [00:21:30] is only 10 address looking and it can store around 2000 so what means that in place of [00:21:39] maintaining 100 trees simultaneously i am maintaining just one tree hitting [00:21:46] maintaining multiple bst will be very much difficult so now we have just to maintain [00:21:52] and we know that in in array to store the addresses we have to just store the address [00:21:57] of the first value okay okay and when we have multiple such small small small array so we have [00:22:02] have to store all the information so so the this is the thing there if we are in a very layman term [00:22:11] we are cooling a room with a let's say three turn air conditioner and someone say i will apply [00:22:16] six point five ten point five ten ac so which one is efficient of course three turn will be [00:22:22] efficient because and because we are overusing it okay so so basically so we can think of like [00:22:30] though we can implement it it will have some sort of drawback like binary binary tree but [00:22:35] the more efficient one would be the b tree yeah yeah in organization wise in putting the things [00:22:42] into the memory yeah yeah okay sir thank you sir look not you can go next good morning sir so last [00:22:54] solution can you just go to that page that 50 60 was in a root node right it is uh [00:23:03] there should be one element or so this is so on basically each level we will have a set of elements [00:23:11] so it is if you see maximum key allow was two so 50 60 could be maintained if it was already full [00:23:17] then one node will be pop up and a label will increase further then that is not the root node [00:23:23] right now right 50 60 there together 50 60 together is a root root is allowed to have [00:23:29] 2 to m child minimum child is 2 and maximum child could be sorry 2 to m minus one child so 2 to [00:23:38] sorry root is allowed to have one key to two key in this scenario so here there are two keys so it [00:23:44] is root if it is one key then also it is root okay okay so getting a point the root node does [00:23:53] not mean that always it will have a single value it can have multiple value depending upon the [00:23:58] order of the tree so if order is m so m minus one key could be accommodated on the root and minimum [00:24:05] allowed is two yes okay okay so i was thinking that that should be only one element no no no [00:24:10] one element is the extreme case okay okay you can go next now okay hello sir good morning [00:24:28] good morning sir i have a query regarding assignment three so what would be the syllabus for [00:24:34] Assignment 3 will be till AVL [00:24:39] property, I hope. [00:24:43] So, it will not [00:24:47] cover inventory even [00:24:49] or somewhere it will cover. [00:24:52] Sir, everyone is done. [00:24:58] Okay, thank you. [00:24:59] Thank you, Jeevan. [00:25:00] Now, there is another critical thing [00:25:03] that we will do that is deletion. [00:25:07] So, [00:25:07] So, this is a structure I had made, handmade. [00:25:11] So, if we are deleting from the leaf node, if we are deleting from the leaf node, leaf [00:25:17] node means that there is no further child. [00:25:23] So, what could be the scenario? [00:25:25] The leaf node contain the more than minimum key, because we have to maintain what? [00:25:32] m by 2, 2, m child or key could be m minus 1, okay. So if child is let us say 3, so key [00:25:42] could be 2, okay. So if it is having minimum, more than minimum, for example, a 5-bay tree [00:25:49] can have minimum, minimum number of key will be how much? 2. Key will be 2 and child will [00:25:55] be, minimum child will be 3. So if it is having more than minimum, so we can simply remove [00:26:01] it no worries if it is having just minimum and we want to remove one node then what we will do [00:26:12] so there is three possibility so we will borrow a node from our left sibling or right sibling okay [00:26:21] so if both are having minimum more than minimum no worries if both are having just minimum then [00:26:29] we will do a merger and height will be reduced. So one by one I will tell with the example rather [00:26:36] than going into the theory because when we visualize then again we will come back and [00:26:41] see how this property was utilized. Now this is a tree and this is a very famous example. [00:26:54] It will cover all the cases. Now we have 50, 80. The order of tree is what? 5. So maximum allowed [00:27:05] key is 4. Internal node can have 3 to 5 chime and key will be obviously 2 to 4 keys. There [00:27:22] is a cap over the minimum. And root can have 2 to 5 chime and 1 to 4 keys. This information [00:27:37] mandate okay so now we want to delete 64 so go to 50 50 says yes i can accommodate so um [00:27:47] because i had no node on my right so you should search so now it go here so 60 says you 64 could [00:27:55] be on my right and 70 says 64 could be on my left so they go down now we identified 64 here okay [00:28:05] Okay. And what we want? We want to remove 64. [00:28:12] So, the minimum allowed keys is what? 2 to 4. [00:28:19] And here number of keys are 1, 2, 3. [00:28:21] So, I can remove easily 64 and we will see the resultant trees looking like this one. [00:28:26] Okay. Because when a node is having more than minimum number of keys [00:28:30] and we want to remove a node from the leaf, then what we will do? [00:28:34] we will simply remove it. So, 64 we have simply removed. Now, we want to delete 23. This is [00:28:47] the critic here. This is the resultant one. Now, in this tree, I want to remove 23. So, [00:28:52] 23 first we will search 50 left 20 right and here we found 23. Now, this node, this node [00:29:08] is having how much two key and two key is the bare minimum okay and there is no right sibling [00:29:15] sibling i hope everyone understand so here there is no right side of this node so there is no right [00:29:20] sibling but there is left sibling okay and then it asks its left sibling i am having just bare [00:29:31] minimum are you having more than minimum so it says yes i am having three node and as per our [00:29:37] rule, we required only 2. So, what will happen? A node from the left sibling will be going [00:29:48] to replace 23, but it will be channeled via the root. It will be channeled via the root. [00:29:54] So, what will happen? 60 will be removed, 16 will be removed, it will replace 20 and [00:30:01] then 20 will come down. So, this is a tricky part. What I say, when I have just bare minimum [00:30:10] node, then I will look for the left or right sibling. But in this case, there is only left [00:30:18] sibling. Now, it will ask left sibling whether you are having more than minimum node. So, [00:30:28] So left sibling say yes I had because minimum required is 3 and I had the minimum required [00:30:34] keys is 2 and I had 3. So I will provide one of my key and you can easily remove 23. But we know [00:30:42] that there is no direct access in between these two siblings. So it will be passed via the route. [00:30:48] So 16 will replace 20 and we know that from the left sibling which node will be picked the [00:30:56] highest one. That already we understand. And that will replace this one at 20. And if there was [00:31:04] right sibling, for example, we were removing six. And there was only two nodes. So minimum from the [00:31:12] right sibling will be picked. So there is an important information. If node is having [00:31:21] bare minimum. So, what will happen? First, it will ask highest from left or if exist, [00:31:45] it will ask lowest from right. This is clear and it will be rooted through, it will be rooted through, [00:31:58] it will root it through, rooted via root. So they will not directly come, they will be rooted via [00:32:09] root node. So for here, there is a root node. So 16 is the largest key in this. So it will replace [00:32:17] 20 and 20 will be replaced by the 16 and then 20 go down and replace 23. [00:32:24] so the resultant tree will be this one there is no node here and 16 gone up and 20 is here now [00:32:33] node 23 is there i hope you will understand so if you remember this was the scenario because we are [00:32:43] dealing with the node of removal node in the leaf one so the leaf node contain the minimum tree then [00:32:50] what we will do brow borrow from immediate left node sibling or borrow from immediate right but [00:32:57] there was no right. So, we had borrowed from immediate left. But this could be situation. [00:33:04] So, we will see later on where though left and right sibling persist, but they do not have any [00:33:11] extra node. So, what we will do in that scenario, we will talk about that. [00:33:15] Now, we are targeting to removal of 72 from above node. So, where is 70 to 50? [00:33:21] right 80 left then 60 right 70 right 72 left so here we find we find 72 but it have both [00:33:38] left sibling and right sibling now if it go left sibling it is having bare minimum i will not [00:33:48] provide then it will go to the right right say yes i had more than because i need two and i [00:33:55] am having 3. So, it will say because I am right sibling, so you will get the smallest element. I [00:34:01] am right sibling. So, you will get the smallest one. So, now what will happen? Now, what will [00:34:22] happen? 77 will go up, replace 75 and 75 will come down and replace 72. So, of course, the order [00:34:34] will be maintained so 73 will go forward and 75 will be added here so that what what we did 77 [00:34:41] is replacing 75 and 75 will come down and take its specific location okay so here what we have [00:34:48] witnessed the next case that was borrow from the immediate right so when we are borrowing we will [00:34:53] borrow the smallest and here we will borrow the largest okay so i hope this is clear now [00:35:08] there is a critical deletion. There will be a critical deletion. We want to delete 65. [00:35:20] We want to delete 65. I hope everyone is getting the deletion by taking the help from left sibling [00:35:27] or right sibling. Now, there could be third case where we have to remove a node 65. So, [00:35:37] let us see where 65 is. So, let us see in this. So, 60, 50 says my right, 80 says my left, 60 says [00:35:45] my right. So, here we encountered 65. Now, if you see left sibling is having 2 and right sibling [00:35:55] is having what? 2. So, both are having bare minimum. So, what we will do now? So, that is [00:36:00] is a tricky part. So, I will say one statement, if both siblings are having bare minimum nodes [00:36:29] or sorry keys then then merge merge the node with either left or right that is very important [00:36:56] merge node with either left or right and bring down the parent from the root. [00:37:14] So, what we will do when both the nodes are having bare minimum. So, we can either choose [00:37:22] left sibling or right sibling and what we will do we will do a merger. So, when these two nodes [00:37:28] are merged, one node will be bring down. So, 60 was the parent of these two node, we will bring [00:37:34] down and remove 65, the resultant tree will be likewise. So, 60 was come down and these two [00:37:42] nodes were merged and now this is the resultant tree. So, again I am repeating, I have to delete [00:37:52] 65 and what we have identified both on the left part and right part there were bare minimum. So, [00:38:00] what we can do? We can merge with left or merge with right and while merging we will bring down [00:38:06] one node. While merging we will bring down one node and that node will be the parent of the [00:38:13] both node. So, if we merge left sibling, so the parent is 60. If we merge right sibling, [00:38:18] then the parent will be 70. So we bring down 60 and while we bring down 60, 65 will be [00:38:28] removed and it will be placed on its appropriate place. So if you remember that graph, so merge [00:38:36] the node and bring parent down. This is the scenario. If the leaf node is having more [00:38:42] than minimum simply remove it if it is having bare minimum look out the left and right sibling [00:38:49] if they are having sufficient node so we can bring for left highest and for right lowest [00:38:55] channel through the root and the node will be replaced if both the left sibling and right [00:39:03] sibling are having bare minimum then we will do a merger and bring the parent down i hope [00:39:08] you people get it now let us take let me let me take the queries and then we will talk about other [00:39:14] other for internal nodes yes uh yeah given in uh someone are raising hands uh one by one one yes [00:39:38] sir good morning am i audible sir yeah yes yes please sir uh so uh as we understand uh if you [00:39:44] can just go to the previous slide sir where you were uh uh yes sir so uh this is something like [00:39:52] Now, if we see the 16 and 23 example which you've given, so it is something very similar to the LL rotation and RR rotations of the AVL tree to balance out. [00:40:02] And in this case, it is because of the rule. [00:40:06] Yes, yes, yes. [00:40:08] Yeah, yeah, yeah. [00:40:10] Yeah, yeah, that is like a rotation. [00:40:11] We are doing the rotation to balance the tree. [00:40:14] And in this case, we are doing the rotation to maintain that key node values as per the rule of the B2. [00:40:19] Yes, yes, yes. [00:40:21] Okay. [00:40:22] Now, sir, my second question is, you have given an example where the left and the right both have minimum number of keys, correct? [00:40:29] Yes, here, here. [00:40:31] Then we do the deletion and the parent is brought down to this thing. [00:40:35] That parent brought down is important, otherwise parent-child relationship will be violated. [00:40:40] Yes, the minimum key violation will be there on the note. [00:40:43] Yes, sir. [00:40:44] So, my question is that if left and right both have the maximum keys, so which one can we give preference? [00:40:50] Anyone? [00:40:51] Anyone, anyone. That is your choice. [00:40:54] So there is no priority. [00:40:55] No, no, no, no, no. [00:40:57] But usually, usually [00:40:59] in our, you can say, [00:41:01] as a person, we prefer [00:41:03] left always to come up. [00:41:05] But that is not a [00:41:07] strict rule. Right, sir. [00:41:09] Thank you, sir. Thank you. That was my question. [00:41:16] Yes, you can go next now. [00:41:18] Hello, sir. Yes, yes. [00:41:20] Good morning, sir. Good morning, sir. [00:41:22] Most of the example that we have seen [00:41:24] so far, [00:41:25] uh if you see in in any of the nodes uh we we don't have the duplicates right duplicate is not [00:41:33] allowed in b tree ah okay it's a prerequisites yeah that is there i mean b plus three we will [00:41:41] see duplicates are allowed but in b tree there is no allowance of duplicate okay okay okay thank you [00:41:49] do you want to ask your doubt or is it okay so jessie you can go now yeah thank you uh good [00:42:20] morning sir when we were deleting 65 we brought the parent down and we took the merge the remaining [00:42:29] also to the left side why can't we do it like um we can bring the 68 to the parent right 68 70 72 [00:42:38] and we can bring the 60 down right that will also not violate what you are saying 68 will go up i [00:42:46] guess yeah and 60 will come down so that could be one property but but in the literature this [00:42:54] specific rule is mentioned that what i am teaching you can make of it your own so what will happen [00:42:59] in that case now you have to every time identify the this replacement and other stuff of course [00:43:05] 68 when it will go up [00:43:06] so there will be only one child of 68 [00:43:09] that is 51 and [00:43:10] 55 [00:43:11] 51, 55 and [00:43:15] 60 [00:43:16] 51, 52, 60 [00:43:18] and there will be no [00:43:20] you can say right child of that [00:43:22] 68 [00:43:23] 68, 70, 77 [00:43:28] will combine together [00:43:29] 68 comes [00:43:32] so there will be no child here [00:43:34] there will be no child [00:43:37] all will be placed here 51 52 and 60 that is the case yeah yeah so so basically what if [00:43:47] if we go ahead when we will talk about b plus 3 so there what we will do it is we will never [00:43:54] keep a situation where leaf node of where there is no part to the leaf okay so that is one one [00:44:01] reason as well but if you are missing so you can propose one you can come up with one modification [00:44:05] that we can do like this one. But in B tree or in B plus tree, there is a must condition [00:44:12] that a node should add a leaf kind of node. So, that is the reason we are not targeting [00:44:18] that. So, every left and right should have a leaf. Yeah, leaf. So, because if you talk [00:44:27] about this arrangement, hierarchical. So, if we miss that, then we are missing certain locations, [00:44:33] we are not touching it hitting okay so your your property is valid okay your your policy is valid [00:44:42] so it will be true you can say it is a variant of b3 but later on when we talk about the databases [00:44:49] then this will fail yes sir i think that will violate one of the cases because we should have [00:44:55] minimum number of five by two so if we take 65 like 68 up and march then it would have only two [00:45:02] children's in that case so i think that would violate because it would have minimum it will have [00:45:07] three three to five uh five 51 50 so she is saying 60 will come down and it will be replaced by [00:45:14] uh 68 so we will have 51 52 60. so that is another variant of algorithm also but it would [00:45:21] have like two children's only right at that time 70 75 and then it would have like two children [00:45:26] one is for 51 52 and 68 and then another one is 73 and 75 no so i will just draw that note okay just [00:45:37] to be so what's he's telling 68 70 75 and this will have one address pointer to 73 and 75 [00:45:48] there will be no child for this one and then the here will be 51 52 and 60. so of course here we [00:45:59] are having four child so that is allowed but sir minimum number but sir minimum number should be [00:46:08] five by two right ceiling of five by two three so minimum is three so here we are having four one two [00:46:15] three four though there is no pointer but it is it exists okay so like null pointer are also [00:46:21] yeah that is also count okay given doubts are done so we will see how we will delete [00:46:49] yes yes but yes yeah hi sir yeah hi sir so what does it mean by both sibling has bare minimum key [00:47:02] how it's i didn't get that one okay good question so here for 60 if we want to delete [00:47:12] 65 so its left sibling is what 51 52 and right sibling is what 73 75 so the minimum allowed key [00:47:21] was what 2 because the child was 3 so both the nodes have 2 2 so how we can bring or ask them [00:47:31] for a key because they are just running so 51 52 is 1 and 1 is 73 75 sibling means that the cousins [00:47:38] so here 65 or you can say 68 so this is also having minimum and this is also having minimum [00:47:47] so that is called bare minimum node that is minimum two that was required so that they have [00:47:53] getting are still not getting okay thank you okay everyone is completed yeah yeah thank you [00:48:04] given. So now we will talk about little bit more complicated cases. Now in the same example, [00:48:12] if I want to remove 20, see this. So 50 left, 16 right and here we encountered 20. [00:48:23] Now the situation is critical because it does not had any right sibling, just left sibling is there [00:48:29] and in this case we cannot ask because this is having two nodes. So what we will do, [00:48:35] we will merge and bring down 16 that is obvious case but when we try to bring down 16 so there [00:48:42] is again a violation of minimum key at this label okay so what we will do then we will merge with [00:48:50] this one and bring down 50 16 will come down so two step will be there two steps will be there [00:48:57] So, what we have did, we have bring down 80. So, just I want to remove it. So, if I want [00:49:17] to remove 20, so what will happen? So, 16 will bring down and merge the node that we [00:49:29] understand easily. But when we try to bring down 16, but when we bring down, want to bring [00:49:38] down 16. In that case, what will happen? It is not allowed because it will violate the [00:49:44] minimum key or minimum child property. So, what we will do? We will bring down 50, merge. [00:49:50] So, 10, 50, 70, 77 will be formed and there will be a new node that is 14, 15, 16 and [00:49:59] 27. So, if you see the resultant, so 14, 15, 16, 77, 10, 50, 70, 77 and just we have bring [00:50:07] down and root is allowed to have two child that is there okay so this is you can say cascading [00:50:12] one if we want to bring down 16 we have to also bring down 50 because it will violate the if we [00:50:19] don't bring down then it will violate the b3 property that is the internal node should have [00:50:26] minimum ceiling of m by two nodes and maximum m nodes okay and root is allowed to have two child [00:50:35] So, I hope this is clear. So, this is bit tricky. So, while deleting 20 understand there are two [00:50:43] deletions. We have to first delete 16 and 16 deletion required what? It required bringing [00:50:50] back the parent 50 and merging. Then that 16 is stored in the temporary location will go to [00:50:57] downwards and 14, 15, 16, 20, 27 will be 20 will be removed and the new node will be formed. [00:51:05] Now, in this tree, so I hope all the cases are done when the, we want to remove the node [00:51:14] in the leaf, leaf is done. [00:51:17] Now we will talk about the internal nodes, deleting node in the internal. [00:51:25] So just taking a quick break and we will start, I am, I will, okay, now let us go to the scenario [00:57:08] where we want to remove internal nodes okay so in the above tree what we have obtained [00:57:14] after two label of merger we want to remove 70 so identify 70 80 left here is the 70 okay [00:57:25] and if you remember mway tree so what we were doing we were removing the the node with the [00:57:31] in order successor or predecessor or we can say the highest node from the left or the [00:57:36] lowest node from the light will replace it. So, here if you see on the right there is [00:57:40] no possibility because this is having minimum 1. So, from here we will bring 68 up and that [00:57:48] will replace 70 and 70 will be deleted in this. So, this is in order predecessor or [00:57:55] we can say that highest element from the highest element from the left ok so this is easy to [00:58:12] go now we want to delete 95 in this ok in this node after getting sick i want to delete 95 where [00:58:21] is 95 here is 95 here if you see this is having three and this is having two so again 100 will [00:58:32] bring come up so this will be in order successor in order successor okay this will replace okay [00:58:47] so 100 is coming here so this is also clear so there are two possibilities we can replace it [00:58:52] with in order predecessor or we can replace with in order successor okay now one question arises [00:58:57] why sir, we cannot directly remove it because they are having associated child pointers. [00:59:03] Okay. Now, here the question comes. We want to delete 77. So, 80 is left, 77 is in counter. [00:59:14] Now, here we cannot apply in order successor or in order predecessor because both are having the [00:59:21] minimum so what we will do we will merge them we will merge them so what we will do we will bring [00:59:33] 77 down merge them and remove it so what we are doing bring 77 down merge the two siblings okay [00:59:46] just I will write clearly bring node down and merge the two siblings okay so we have [01:00:05] merged and bring down okay so you can see I hope the things is clear because 77 does [01:00:14] not have a sibling that can have more than minimum key. So what I have done, I have removed [01:00:24] 77 and merge both the key simple you can say remove the node merge both the sibling remove [01:00:31] the node merge the sibling. Okay, this we have dead. Now I hope this is clear. Now next [01:00:44] one removing 80. Removing 80, 80 is where? If you see here 80. Now one says, now well [01:00:51] let us remove 80. So while removing 80, what we can do? We can bring in order predecessor [01:00:59] or in order successor, whatever required. But here if you see in order, successor is [01:01:05] having just bare minimum. In order successor here will be 81, not bare minimum. In order [01:01:13] successor will be 81 and in order predecessor will be what in order predecessor will be 79 so [01:01:19] you can bring any of them so 79 is coming here okay now if we want to delete 100 so 100 is here [01:01:28] and if i remove 100 then there is will be merger of this one but the condition is if i delete 100 [01:01:36] then what will happen the minimum node property will be violated so removal of 100 will be [01:01:42] required what 79 will bring down a solid node will be formed and then these two node will be merged. [01:01:49] So, these are the all cases that we can do in the RB deletion. So, again I am repeating the [01:01:59] internal nodes deletion. Just remove all those stuff. So, afterwards what we are doing, [01:02:21] we are removing internal node. So, removing internal node, so first we are targeting removal of [01:02:41] 70. So if you want to remove 70 here, so we can ask in order predecessor or successor. [01:02:47] So there is no node in the successor, extra node. So we will bring 68 up and the things [01:02:52] will remain done. Now if we want to remove 95 from this, so 95 is here. So we do not [01:02:59] have node in the predecessor. So we will bring successor up and this will be the resultant. [01:03:05] Okay. Two cases are clear. Now we want to remove 77. So 77 is having both left sibling and right [01:03:11] sibling with minimum. Then what we will do? We will remove it and merge them. We will remove 77 [01:03:16] and merge them. Okay. Now we want to remove 80. So 80 can be removed from its predecessor or from [01:03:28] its successor. So predecessor of 80 is what? In order predecessor is 79. And in order successor [01:03:34] is 81 so either we can remove it with 81 or 80 because these nodes are having more than minimum [01:03:41] node if it is not having more than minimum then we will look after here okay now then we want to [01:03:50] remove 100 here if we want to remove 100 okay if you want to remove 100 here so 100 is having can [01:04:06] be removed but both the siblings are having minimum one but if we remove 100 then what will [01:04:12] happen this node will be unstabilized so what we will do 79 will bring down a new node will be [01:04:17] formed and this node will be merged okay so I hope all the scenarios are clear then there are other [01:04:28] example that we will see but up till this if anyone has doubt let me know then we will see [01:04:33] one more example now given anyone is not having any doubt so whether I am teaching very good or [01:04:52] you people are everything is going on no no no varoon is there yeah sir can you repeat the [01:05:01] 81 once again i missed it once again okay so removal of 80 yes this this one 80 what we will [01:05:09] do we want we it will be replaced with in order predecessor or in order successor okay so in order [01:05:25] predecessor is what 79 and in order successor is what 81 and 79 is in the node that is having more [01:05:31] than minimum 79 has come up you can also come up 81 because it is also having more than minimum so [01:05:36] that is the case getting your doubt is done yeah so you brought it from the leaf node why not i [01:05:51] have brought it not from leaf node i have brought it in order predecessor in order predecessor is [01:05:57] the node that is just less than this one okay okay okay okay there is no entries now yeah [01:06:07] everyone done sir okay so what i will do give us sorry one more sir one more please please please [01:06:14] he wants you can go now am audible yes yes you are audible sir when we remove the 77 in the [01:06:25] previous slide yeah so when we removed the 77 we merge uh the below child properties like 73 75 [01:06:35] 78 79 yes so when when we delete 77 so uh to which these these figures will point to like [01:06:44] this is 68 68 right 68 right will be 73 75 so here you can see now 68 right but it caught it [01:06:57] thank you okay so uh what i will do because um we have cover up uh you can say complicated thing [01:07:11] so i'm stopping here and the next class uh we'll see one more example then we will start the [01:07:17] heap so heap will be the last topic or not arbitrary is there and afterward we will jump [01:07:23] into the graph so in the next on the saturday lecture we will try to start the new thing that [01:07:27] is graphs. So, I am closing here because it is not better to start a new part here or let me [01:07:35] complete these some examples here. One more example I am solving for B tree deletion and [01:07:41] then we will proceed. So, now here we want to delete 6. In this node we want to delete 6. [01:07:50] So, 6 is here, simply remove it because it is having more than minimum because this tree was [01:07:54] 5 order so 6 we can easily remove now we want to delete 27 find 27 27 is here so if 27 is [01:08:02] deleted no worries we can easily remove the 27 okay because it is having more than minimum now [01:08:08] we want to delete 60 60 is having more than minimum 16 more than minimum so 16 and 66 can be easily [01:08:15] removed okay now we want to delete 50. now in this tree we want to delete 50. so what will happen [01:08:24] If we want to delete 50, so we will ask with the left sibling, right sibling, no more available. [01:08:31] So what we will do? [01:08:32] But if we remove 50, then this 68 will bring down. [01:08:35] This 68 will bring down and then these two nodes will be merged. [01:08:40] So what we can witness, the resultant will be 10, 68 will be here and this one. [01:08:51] So this example, I hope is clear. [01:08:53] So I am stopping here. [01:08:55] New topic, we will start in the next class. [01:08:58] okay so thank you Jeevan so though today's lecture was short but yeah I will take the [01:09:04] queries two more people are there yeah yeah please so they can ask you can check your [01:09:12] term yeah can you hear me yes yes yes my question is that sir in an exam do we need to actually [01:09:22] implement all these delete insertion operations or like understanding is enough understanding [01:09:27] will be more than enough okay okay thank you sir sir uh actually i have a doubt uh where we did [01:09:40] something uh like uh change in the merging procedure uh like uh can you go to the slides uh [01:09:49] like uh where we have deleted like 65 or 70 that was one of the key where we have deleted it [01:09:58] delete 65. ah sir i think i think one slide above before like this yeah yeah so this was [01:10:07] the case where you told that the null pointer is also considered valid so i think for the internal [01:10:14] node i uh as for my understanding i we don't think that null null pointer would be a valid one [01:10:22] because for internal load sir number of children must satisfy so null pointer is not a valid one [01:10:29] so here number of children is four okay in this example though this was out of track example [01:10:36] but here there is a children but there is no association so there is a address there is a [01:10:41] pointer but that is not that if we if we consider null pointer as valid sir then in case of skew [01:10:48] tree also that would also be like b tree that would also follow the property of b tree because [01:10:54] in this case this would be the internal node right 68 70 and 25 then it's q tree also we [01:11:01] can consider that okay there are null pointers so uh if you consider null i totally agree but [01:11:07] that was a special thing someone was discussing so i make but in case of b tree now you will [01:11:11] never find this kind of situation no sir basically yeah so basically sir if [01:11:18] that's the case that this uh like this merger is invalid basically that is what i want to say [01:11:24] yeah yeah so that that was the special thing someone was discussing so i make it but it will [01:11:28] never happen in between okay okay okay i think yes hello sir good morning sorry good morning [01:11:42] yeah uh actually my question is uh regarding the quiz and assignments uh you told that um [01:11:49] you will discuss the questions and assignment questions uh in a lab so we we have completed [01:11:57] our quiz one so uh but today it is not possible maybe in the next week we can discuss or next to [01:12:05] next week when the classes are going um because then the assignment four will be complete then [01:12:10] we are good to go so we will discuss all yeah and also for the quiz one there is a question [01:12:17] that have the uh two options was correct yeah so um someone get the marks on uh of that one but [01:12:28] someone not getting the marks i think so no no if i have i had i remember the question i had [01:12:34] initiated to because uh in height calculation there was a doubt of minus one so i have put [01:12:39] both the cases too so if we attempt that you will get the max if someone attempt other than will he [01:12:44] or she will get the mark so for both one one marks were there yeah it is not one max will [01:12:50] so i intentionally did that because there was a little bit doubt in the height calculation so so [01:12:55] that okay sir no problem then thank you you can go now um so my question is on personal thing [01:13:07] like i missed the quiz this time um what will impact it will impact it overall [01:13:13] overall your grade will be little bit lesser okay because there's no way we can reopen i don't think [01:13:21] the team will allow you okay but don't do uh don't worry do good in your end sem marks that [01:13:28] is having the highest weightage okay but at least i can see the question sir is it possible that i [01:13:36] can see the questions what was because actually someone was previously asking so i have to figure [01:13:43] out whether it is possible for me to see also the questions if i see then i will discuss in the in the [01:13:48] class so i will check it out okay or i will see i will look into the uh my part where i [01:13:54] have maintained a question thing so that i will discuss separately yeah okay thank you [01:14:01] you can check your doubt silpy you can go next i think rossan is on mute [01:14:14] i just want to ask the labels for assignment three assignment three will be till avl or [01:14:22] max to max it will be the properties of mv3 not beyond that okay thank you sir okay i guess [01:14:31] everyone is done thank you thank you yes sir thank you sir