[00:00:09] Okay. So, the same is this one. So, in the last plus, I already told you, like, how the tree is, what are the types of trees, right? But why do we need it? Right? So, why tree came into the picture? Where it is using first? Okay, right? [00:00:49] so um so imagine like uh you are building a file management right and uh on our computer [00:01:05] and then files are something like c drive okay under the c drive there is a [00:01:17] documents is there one folder under that document [00:01:23] and then if you go to the pictures right there are some photo will be there [00:01:48] jpg correct so this is something looks like a hierarchical structure right so if i will [00:02:05] do something like this yeah and do like this so if you will see something like hierarchical [00:02:19] structure one item contains or connect to other items right so in the existing data structure [00:02:26] okay like if you compare to either link list okay array even okay so an array can store all the all [00:02:39] these file names but it doesn't like a directly express their parent child relationship right [00:02:47] and right so a tree can represent those relationships because if you see the [00:02:54] document is a parent of these two files okay the c drive is a parent of documents and the pictures [00:03:01] right so uh we i cannot able to like we cannot able to find uh these type of relationships [00:03:09] so uh so to build these type of relationships okay so we required a tree so in the real life [00:03:18] if you use a file explorer okay in the real life you uh even use in ai right so if you see the [00:03:25] decision trees used for the classification and the predictions right so there also we use the [00:03:31] tree concepts right so in that uh and in the if you see rather than the computer science in the [00:03:41] like a real life of we use in an organization charts right so like a managers then under that [00:03:49] employees and that are junior employees correct so these type of use cases are there okay [00:03:57] so that's why uh tree came into the picture okay so when it came into the picture already came okay [00:04:04] okay people introduce tree okay now what tree is having their child and parent correct so then [00:04:18] a general tree can have any number of children uh in the per mode okay so uh people see it okay [00:04:28] you have any number of children but this is very flexible okay this flexibility is very useful [00:04:39] but it doesn't help with certain number of operations correct such as [00:04:48] searching the searching the numerical values okay let's say you are some something searching right [00:04:54] i'll tell you one example there is a tool for everything okay thanks for everything [00:05:01] yeah it's called everything i have okay if you see there it will search like this one [00:05:08] okay so it search quickly your file names anything like related to your like a like [00:05:16] strings that it starts using regex also okay so uh when tree came uh they told like it can be a [00:05:25] binary tree we're trying to retrieve something like that but this flexibility is sorry flexibility [00:05:38] is useful for important operations like searching. Searching of what? Searching of anything like [00:06:03] it may be numerical values, numerical values, alphabetical numbers, sorry alphabetical [00:06:15] characters alphanumeric character [00:06:20] okay correct so those things okay so then there's the decision is okay binary tree you can say or [00:06:34] like a tree correct so uh no like a uh this no no this needs us to be like a uh like a there is a [00:06:48] this one okay we cannot able to search searching in a sorted numerical values that's where binary [00:06:55] tree came into the picture okay yes little bit of confused okay so this way binary tree came [00:07:04] under the picture so as you know right a binary tree is like in which each node can have at most [00:07:10] two children a left child and a right child right so it gives us a simple and predictable structure [00:07:19] that works well for the like recursive algorithm okay uh like if you go to the parent then it will [00:07:27] go to the child okay then this but uh if you see okay uh it is not necessary okay like a [00:07:37] tree can have many numbers for nodes so binary tree came okay so that we can have a something [00:07:42] limited okay like a two only a children something like that we can have but it is also having like a [00:07:52] disadvantage or like a searching okay same same situation only okay so this is the problem of [00:08:00] of or like a structure we can say this is okay structurally because [00:08:15] it can have many nodes correct and problems [00:08:36] so uh if i'm going to give you one example like a 15 is there okay i inserted one value [00:08:45] like a 10 and 20 correct again i inserted one value [00:08:53] five okay and then i inserted another value for 12 right this is one tree i if you give me the [00:09:03] value i will insert insert insert right when i'm going to find out any value okay it will [00:09:07] be difficult for me okay where is the 12 okay i'll search here okay what is there no no no [00:09:12] 12 is there no if 12 is there no what is that no yes 12 is there so if we search like that [00:09:20] then we have to go some big old fan something like that correct so that's why binary search 3 [00:09:32] came into the picture okay so i'll write here also existing data structure [00:09:52] we are not able to fix the parent-child relationship that's why like binary c [00:10:14] please search in the picture okay so what is binary search stream it it is like a [00:10:23] for values that are coming smaller than the root node we go to its left okay [00:10:31] and values that are coming the greater than the root node will go to the right of it and [00:10:39] right here, and it goes, [00:10:45] I've done it for many, [00:10:49] let me [00:10:53] open, let's [00:11:12] open, [00:11:16] let's, [00:11:25] I hope you have already heard of this, [00:11:29] so if i'm going to restructure this tree okay this is the only restructuring of like a binary [00:11:42] search if i can see because it is already structured right so this is already structured [00:12:00] values are coming uh that is smaller it's already in a left value that are coming greater it's [00:12:08] already right right so so this is how likely uh people also to the binary search okay but [00:12:19] there is also like a problem okay and if we see in a binary search tree okay [00:12:28] so let's say values that are came okay something like this 10 20 [00:12:34] searching was the problem right that's why we came into the picture of a binary search tree [00:12:48] right so again if it is a searching problem then what what we should do [00:12:54] correct that's why there is a two or like a three scientists in abl okay avalanche [00:13:06] i don't know what's the amount is just right yeah adults on well ski and landis okay [00:13:24] so georgie adelson wesky and the landis these are the two scientists [00:13:29] behind this evil tree which is for itself balanced binary tree okay so what what was the problem in [00:13:37] binary search tree is it if it is values came like this okay it will be like a skewed tree okay [00:13:43] in the previous class i already i can introduce to like a skewed tree which is a right skewed [00:13:50] or left skewed right so this is the right skewed one okay because this is uh like going up to the [00:13:56] right so if we search 40 okay we have to go till the down okay and we have to search okay so that's [00:14:03] where like a avial tree came into the picture so avial tree is like a self-balanced binary search [00:14:10] tree only okay and it maintains a height uh balance condition okay it's like a for every node [00:14:19] the height of its left and the right subject differs by at most one okay like a so it's like [00:14:28] they have to maintain in each node one zero or minus one that's it okay in the ukulele trade [00:14:36] correct so i'll give you one home of you okay we will study although like in the next class [00:14:45] so there are three cases and i will take and then show you one okay so let's say your tree is like [00:14:50] this okay if i'm cut down this only let's say your tree is like this okay so if we want to like a uh [00:15:04] balance something like that we have to rotate the tree okay so what we have to rotate we have to [00:15:10] rotate in this way okay so this is the right skew okay so we have to apply the rr kind of things [00:15:16] okay so or like a a little simple i i don't go in that way but i used to see in like a which [00:15:24] way it is like a skewed okay we have to rotate it in the opposite way so let's say in this cube [00:15:32] right so we have to rotate some this way okay so uh 10 10 kind of things so if we rotate it [00:15:40] so we will get something like 10 will be the root no oh sorry 20 will be the root one [00:15:49] okay and but they will be the oh it's right now okay the 20. if we see here it also follows the [00:16:02] binary search string okay because it rotated somehow and also one of the like a well the [00:16:10] smaller node came into the left side or the bigger node came into the right side so this is the [00:16:17] a field to be pen [00:16:20] self-balanced [00:16:28] binary search tree [00:16:33] okay correct so yeah [00:16:42] another tree is there okay so another tree is there [00:16:47] also so this is how if you see like [00:16:51] what came into the cell like a tree is there what are its disadvantage [00:16:55] is from that disadvantage binary tree came okay so from that it was that that disagreement is [00:17:01] binary search tree came okay there is another tree also like a red black tree okay it's kind [00:17:07] of an alternate to evil tree okay so evil tree keeps a strict balance right uh okay either right [00:17:14] rotate some if you go you will see okay and a red black tree uses a different set of rules like a [00:17:22] involving like a red and a black node okay colors to prevent the three formats becoming too tall [00:17:31] okay like a like uh i'll go okay and i'll explain what is that basically it maintains a logarithmic [00:17:43] height okay while allowing the insertion and the delimition with the balancing rules okay so uh if [00:17:50] you see here okay so somehow we maintained a like a binary substrate right using avl [00:17:56] but if we want to delete it okay or if we want to uh okay from the delete deletion mode or okay [00:18:05] then somehow it came uh with some of it like it taking more time okay and if we see inability [00:18:17] deletion part so that's why red like tree came into the picture [00:18:26] so yeah so this is the history of a tree well i will go and produce like a [00:18:36] mass okay we'll study about like a traversal kind of things [00:18:47] yes so yeah so we will study about the traversal [00:18:54] in order pre-order and post-order then we already know about the bsd right my name is [00:19:06] astrid don't have to explain so i explained like what is bsd here okay and uh i don't know [00:19:21] whatever you do um i didn't want to show you it's poor okay what how it's like i look like [00:19:32] it's very simple so so in the last class i sold you like the wrong how you can create one more [00:19:47] right so now snow okay and then def in here self value and all the data you can say [00:20:05] Some data is there, okay, like, so node is created, and then if we, like, we can take [00:21:08] another, like, to insert, okay, so node, value, so we can apply one if condition, okay, if, [00:21:36] so first we will apply this base condition if root is null then you just return return [00:21:53] value click and if value is for many it is [00:22:02] is this then root.data then root.left equals to insert of .left and that values similarly [00:22:35] if value that are coming is greater than .data okay so if not okay and if you return the root [00:23:46] and so this is now like a there's a code of uh core code of like a binary search [00:23:52] oh yeah so this is very simple and then if we go to the more into traversal okay [00:24:06] so traversal like a tree traversal means like visiting the node of a tree in a particular order [00:24:13] okay so there are three orders like a in order pre-order and post order okay [00:24:18] um if i will like i show you in a real life uh where it is using imagine like a [00:24:28] uh tree represents your computer right and you may want to list the folders in sorted order okay [00:24:38] uh you widget the parent okay before its children now or the process the children before their [00:24:45] parents right so something like that you can imagine okay so in the in order we first visit [00:25:18] its left node okay then the group and then the right node and there is a fact like if you [00:25:24] visit in order of a load okay and the bst particularly okay then you will get a sorted [00:25:32] or order of that uh what say numerical values okay so me so for your sake like a mention left [00:25:49] then in the pre-order you first visit the route then in the post order you visit all the left [00:26:16] notes then the all right notes and then route so here route means like a current [00:26:28] know not necessarily the root of entire tree okay so i will also mention here like what [00:26:37] means like a panel not not like the two parts of the tree okay so so if i will take this [00:26:56] example only okay i think this is very easy you think so you can study some other things version [00:27:12] so it will start with the okay okay so what i'm going like the first is in order [00:27:19] okay so in order to our service first um then then it's right right so in the left what we have [00:27:33] is it 15 okay it will start at a 15 then it will go to the left which is 10 then it will go to left [00:27:41] again okay which is likely five then uh five has no uh left child right so it will print that okay [00:27:52] five then it will return to 10 again okay then it will print 10 okay because that is completed okay [00:28:01] then it will move to its uh right children left is completed right then of left is completed [00:28:07] so it will move to the right okay this one so it will come to 12 then it will print 12 [00:28:14] why it was painful because it has no any left children first okay or any right children so [00:28:20] that's why it will it will print 12 there and then it will again back to uh like a [00:28:26] then again back to uh it will see okay so all the notes are completed 12 back to 15 again okay so [00:28:34] all the left children's of the 15 are completed right so it will go to the right children so [00:28:41] when it will go to the right children okay then it will come as a [00:28:48] it will 20 okay so then it will print the 22. so this is how it will traverse okay [00:28:57] so first we printed the 10 5 sorry 5 10 then we could uh print the 12 15 then 20 if we see the [00:29:08] order okay there's something like an ascending order here in page so that is the benefit [00:29:14] and yeah so if we if you want okay like a [00:29:25] something like particular i mean in order like [00:29:35] it will look like something so you take the root north okay you know okay it will check like [00:29:46] if the root is none then you return on to that because in this base condition there is [00:29:52] no any like it will check like there is no any uh left node okay so then it will return okay so [00:29:59] something like that you can imagine if root node is one okay there is no any left child or right [00:30:04] child you return okay then uh it will come as a we write that condition if it is one [00:30:25] then you just return it otherwise you go to its left you know dot left then print that data [00:30:48] already completed okay so let's say it is going to in a recursive manner to the left left left left [00:30:55] left okay so at this some point it will say like i don't have any other children or i don't have [00:31:01] any node i am returning okay when it will return okay to its it is completed right so left is [00:31:09] completed now print will come okay so that's where it will print so root.data okay that's [00:31:17] where we are writing root.data so it will print that data and then it will like a go to the [00:31:25] right children okay so let me complete it so we can write only the root dot data okay [00:31:36] enter then it will go to the right part dot right okay then again okay so root dot right came into [00:31:47] the picture okay so root dot right means root dot right will go to again this root okay so again [00:31:56] like it will check okay so this is not none okay we have some children right so again this part [00:32:03] will call okay so if you see it is calling the right side but the completing the left children [00:32:13] first okay then printing the data okay if there is no any data left okay then it is again going [00:32:20] to the right part okay so that's where we are writing this manner okay so we are writing like [00:32:26] this copy understood uh okay so this is uh something like a travel thing pseudocode kind [00:32:39] of things i have written okay if you included this code with this one okay class mode something okay [00:32:48] and then if you will call like a what we are calling like a list of map of and we are [00:32:55] inputting the values right so that's where it will get me worked okay so we understood like [00:33:04] why we are writing this manner okay in order okay we go to the pre-order right [00:33:13] so reorder is like a first vote then left then right okay so uh another portion might [00:33:39] come into the picture okay why we are studying this what is the real life of use case okay [00:33:45] so i'll say like there is no any use case okay [00:33:50] of this traversal kind of things but i didn't find any use case okay i'm saying okay [00:34:00] rather than like a displaying the sorted records okay and finding the data in in some order okay [00:34:12] something like that rather than that i didn't find any use case [00:34:18] yeah and obviously like a hierarchical structure you want to represent your [00:34:22] so if you will see like a one example the same example i'm taking like if you if i want to change [00:34:40] change something okay i'll change one value only let's say change it to eight okay [00:34:50] then you want to include some knobs here and if i then open here so now i think it is a valid [00:35:35] tree you see so now it is it kind of things [00:35:46] so yeah in the pre-order first we visit the root node okay so we will first visit the root node [00:36:02] okay which is 15 okay and then it will print immediately okay after it visiting then it will [00:36:09] go to the left subtree okay left subtree means this one and then this one 10 18 then it will [00:36:19] so it will visit that then it will 10 will come okay in the pre-order then it will print [00:36:27] immediately and then 8 will come okay it will print then it will say like a okay so all the [00:36:33] left side of it's completed okay of the 10 then it will go to the right side right side what is [00:36:38] that 12 then it will print the 12 and it will come to 20 17 25 that's where it will come all [00:36:48] the notes in. So if I will write it, what order it will write in this work? 10, 12, 20, 17, [00:37:04] 25. Copy. Yeah. So if you want to see the code, okay, so I will just copy it, [00:37:15] because it is almost the same with it, there is no any difference, the line of change only. [00:37:20] okay i'll first complete the order paste paste in data okay yeah that's it so it will first [00:37:53] print the data in the left side then the right side okay that's it for pre-order [00:37:58] then the poster in the same way like if you will see it will the same way okay [00:38:09] let me first left node right node and that in the routine okay the left node means like a uh [00:38:17] it will not print the 15 first even the not 10 8. it will uh print the 8 okay it will print the 8 [00:38:25] because it will go in that way just print the 8 because there is no any node okay and then [00:38:33] then it will go to the 12th, then it will print the 12th, the 12th order, it will take [00:38:50] same example, it will go to next web, it shows, next page, first, print the same, order, I [00:39:20] copy this, paste it here, paste it here, paste it here, paste left, okay, got this, [00:39:48] so this is how it will get, so if you want to see the 8 will come, 12, 10, 17, 25, 20, [00:40:10] then 15. okay so these are the only book concepts okay there is no end of them so [00:40:29] this is what the bst is and then this is what the pre-order post-order in order is [00:40:37] and what we can study next i mean what same is so okay so there are many concepts [00:41:01] we don't have it this case for the third problem okay which one it is okay do you see [00:41:25] okay like this issues doing post order right so there is nothing that if we had [00:41:56] yeah your screen is not visible okay okay there are men okay [00:42:03] so this is the third question i think post-order [00:42:17] yeah no changes to save the cover it means it's already there [00:42:51] I will make one sample. [00:42:54] I will make one sample. [00:43:08] I will make one sample. [00:43:12] I will make one sample. [00:43:15] If you can submit it, then you will make one sample. [00:43:23] So, I will make one sample. [00:43:33] So, like for today, right? [00:43:39] Right. I don't think so. Okay. We'll study something else, which is a plan for particular [00:43:53] but we'll study the AI. Okay. What's it? Can we please explain on the time and space complexity [00:44:28] point sure so dhdk like okay like there is no time complexity like a for this okay i mean [00:44:49] then let's say in the search so in the search part if you see okay binary search right so [00:45:29] you will like a get the time like a just known episodes like in the bst like it's depending on [00:45:37] the only on the height i touch so all the search part is like a come through the login it's like [00:45:46] binary search only okay so it will come and come into the big of login otherwise in the worst case [00:45:53] you see okay in the bst and the search performance it will go to the bigger often because there i [00:45:59] showed you the value right so okay so in this case it will go to the till uh skewed wallah [00:46:09] so that's why it will go to the bigger fan correct so even in the insertion take it same [00:46:16] in the binary search tree in the worst case and the insertions also bigger fan because skewed one [00:46:21] that the worst case may go big of n and in the best case may okay like a in the average case sorry [00:46:30] big of login because we are dividing okay we are something like doing [00:46:37] left measure right so that's why it will go to the big of n login [00:46:41] And same in the case of like a deletion, okay, deletion may be same like spewed [00:46:52] So, [00:46:56] like, [00:47:00] there are [00:47:03] deletions [00:47:04] that will be the same. [00:47:08] Why? [00:47:10] Search. [00:47:11] So, [00:47:12] it's [00:47:14] a [00:47:15] so that's why both are almost same so yeah so this is like a time complexity [00:47:45] again depends on both issues right when i okay hope you understand [00:48:21] um what about the space okay so space nothing just like it is taking on the height right [00:48:40] so auxiliary space like a because it uh it is like a big of a h we can say okay we can say h [00:49:17] and if we see the code of it of a dst confirm any it all [00:49:21] So if you see something here, we are not taking any extra space also, right, rather than this [00:49:37] three variable, okay, so I don't think so, like, we are taking any space also, okay, [00:49:50] So, array of a, N, correct. Something around N, Lillian, correct. So, this kind of space [00:50:04] complexity, we go to N, in the worst case, correct. So, and, this kind of recursive [00:50:12] recursive so there is no any space right no space because hp so big of one on us right [00:50:25] big of one okay you can say big of one in the case of a bst yep because it calls will take space yes [00:50:48] it will take space okay but it will all when it will it is returning to that function okay [00:50:53] it will create the heap memory for like a some like if some four milliseconds okay then it will [00:51:02] like a temporarily it's created for the temporarily then it will like a guy right so whatever like [00:51:09] we are taking the space we are taking the space for the that variable like a data okay left [00:51:15] oh yeah right okay so these are the two two three things okay we are taking space otherwise we are [00:51:21] not taking any space right recursive stack if we consider okay i mean this [00:51:37] hey how are you is there any day like real time is please uh there we need to [00:51:48] both a deletion as per uh things of the next okay so in the deletion and the instruction if you see [00:51:56] uh in the file explorer okay if you see your file explorer to delete any file okay and as i [00:52:03] say even when you delete it right spectrum does it [00:52:19] yeah this is this is only the real life use case and i think so [00:52:23] uh this is also five different kind of things and once i have dropped it [00:52:48] i mean in terms of industry industry in my way of computer science like a [00:53:04] you ask me like a kind of these solutions otherwise i want to have anything okay [00:53:19] okay so next concept up here i have always that's gonna collect my screen say stop [00:53:39] there is that like what are the concepts it comes so there are some concepts out there [00:55:17] in the field of yeah okay it's you need just to be everywhere thought of like that uh [00:57:10] language okay let me tell you that language right on yeah so so triton is a language okay [00:57:40] where like it used to like what we can say it is used to like optimize the gpu kernels okay [00:57:51] you can use and write the logic for some it's really like concrete python only [00:58:04] so these things there are many concepts out there which you need to study [00:58:21] and another is the neural tangent kernel okay so it's something like a mathematical framework okay [00:58:35] there are certain neural networks ones you want to see okay so there it is these are some of the [00:58:51] concepts you you obviously heard of like a um recognition recognition then and then some cna and [00:59:08] IOU, mean, precision, correct? You also have to learn these things. [00:59:24] What is distribution technique? What is optimization? Something like that. [00:59:52] Do you have any doubts rather than this, including this class or rather than this class? [01:00:00] although AI knowledge and the Makarata English base disrupts the range periods.