[00:00:07] So, in the previous class we have started a discussion on recursion and before that we were discussing about the closest pair point and where our target is to identify the set of or pair of points which are closest to each other in a given set of point. [00:00:37] So, in a given set of points, we have to identify the closest point. [00:01:00] This is our target and what we have seen that here we are using the median for partitioning [00:01:06] and we know that when we estimate median, we have to sort the values first. [00:01:12] So, for 1D, it is no issue, we can sort and for 2D, we will prefer x coordinate as a point for [00:01:20] sorting because we know that in two dimension, we have two point x and y. So, we will consider [00:01:25] x as a point for doing the sorting. So, here the primarily we are estimating the median. [00:01:33] okay and we have also seen that the closest pair point can also be iterative or recursively solved [00:01:42] via the divide and conquer mechanism okay via divide and conquer okay now uh yesterday we have [00:01:56] started discussion on recurrences or recursion so we have already seen that in divide and conquer [00:02:02] approach, the algorithm like merge sort, quick sort, binary search, whatever we have covered [00:02:10] is following the strategy of recursive division. And thus, all the algorithm that we have covered [00:02:25] so far in divide and conquer will be treated as a recursive algorithm. Why recursive? Because [00:02:31] Because if you talk about the lateral mini recursive means that repeating itself, repeating [00:02:46] itself, repeating itself. [00:02:51] So we have already seen the division part was iteratively or recursively repeated till [00:02:57] we have reached to a situation that is called as the base case. [00:03:02] In most short it is one element label. [00:03:09] recursion already we have understand has primarily two cases that is base case and [00:03:14] the recursive case base case is the you can say stopping criteria area and recursive case is the [00:03:27] iterative or recursive call okay it is this is also called as iterative or recursive call so [00:03:33] for example in case of merge short for division we are continuously calling division merge short [00:03:37] merge sort merge sort n n by 2 n by 4 n so on and there are certain initial conditions okay so [00:03:47] this is not applicable in everywhere but some situation this this could be there so this is [00:03:52] could you can say special case where along with the base condition initial condition may be [00:04:01] specified to determine the value of the function for smaller input size say for example our [00:04:07] algorithm is appear after and when value of n is 6 or above. So before this, we can apply [00:04:15] certain function or something. So that could be a initial value. But these conditions are rare. [00:04:20] Then we understand one thing that there is a notion of well formed recursion. So what is [00:04:31] well formed recursion? Well formed recursion is that after each recursive call, the smallest problem [00:04:38] will tend towards the base condition. If it is not happening, then there will be an issue in the [00:04:44] convergence of the algorithm. So, in each call, in each recursive call, [00:04:59] the problem will tend towards the base case. The problem will tend towards the base case. Then [00:05:19] Such type of recursion is called as well-formed recursion. And already we have understand [00:05:27] that why, how did these recursive cases are there. And we were also discussing that [00:05:34] when we have a recurrence relation, for example, in case of merge sort, this was the recurrence [00:05:40] relation or in case of binary search, this was the recurrence relation or in case of stress and [00:05:50] matrix multiplication the relation was so directly we cannot claim complexity is n log n [00:06:02] the complexity is log n up the complexity is n to the power 2.81 so how to estimate these [00:06:10] exact values how to estimate these exact value if there is a recur recurrence relation given to you [00:06:16] so these are called as the recurrence relation recurrence relation for this is for merge sort [00:06:35] this is for binary search and this is for estrescence. So, how to determine the computational [00:06:46] complexity of estrescence algorithm or binary search or merge sort for a given recurrence [00:06:53] relation. So, here if you see tn equal to 2t n by 2 plus c of n some constant and when [00:07:09] n is greater than 0 if n is 1 then we will stop. So, that is you can say this is similar [00:07:16] to merge sort if you forgot about the constant value. Constant value means that some number [00:07:24] or some value that is given. Then we understand one interesting problem that is tower of Hanoi [00:07:31] problem that hold a different kind of recurrence relation that is t n equal to 2 t n minus 1 plus [00:07:38] 1. So, here if you see it is not happening by 2, it is just reducing by 1. But the good thing is [00:07:44] that it is reducing in each iteration. Therefore, the algorithm will come up though it will be [00:07:50] not as fast as merge sort. Then we understand that there are some technicalities where in case [00:08:00] of this estimation of computational complexity, we ignore the corner cases or boundary cases. [00:08:08] Likewise, during division, we are assuming that the two half of an array are always equal, [00:08:15] but this is not the case because in case of odd number, one array will be one greater than the [00:08:21] next one. So, this will never happen. Now, then we started looking on the three types [00:08:38] of mechanisms for solving the recurrences. First one is substitution method or this method [00:08:43] is also called as guessing the solution method. Next one is recurrence tree or iteration method [00:08:51] And third one is master theorem or master method that is quite interesting. [00:08:57] So guessing the solution is the case when we are very much used to with these kind of [00:09:05] problem and seeing a recurrence relation we can easily convey that this is a, this could [00:09:11] be the computational complexity of this recurrence relation. [00:09:14] Then what we will try to do then via proof of, via induction we will try to establish [00:09:20] that what we have assumed is correct for the recurrence relation. And if we found it is [00:09:25] correct, then we declare that it is the computational complexity. Likewise in this problem, likewise [00:09:35] in this problem, so making a good guess is always a challenge. Making a good guess is [00:10:08] always a challenge and this could come with the experience and we are very much used to. [00:10:15] So this substitution method is often not considered as a good approach because we have to guess [00:10:24] a solution. [00:10:25] And even if after guessing the solution, likewise for this we have guessed this solution, already [00:10:30] we know. [00:10:31] So there are certain other aspects, the boundary or corner cases, here it is floor, here it [00:10:38] is this plus some 17. [00:10:40] Okay, so again also this is look like log of n because we are ignoring the boundary cases. [00:10:54] Okay, now, so what is the basic step of solving the recursion? Guess the form of solution. [00:11:03] Okay, then using mathematical induction find the constant and so that the solution works [00:11:10] and if it work then that is fine. So, yesterday we have seen one problem 2t, [00:11:15] so this is likewise floor of n by 2 plus n. This recurrence relation is given and we have [00:11:24] guess of solution that it is n of log of n or basically if you see here we go of log of n [00:11:30] maximum or you can say worst case computational complexity of this recurrence relation is [00:11:36] n of log of n that I have assumed. Now, if you remember for this one what was the condition? [00:11:47] f n is less than c of g of n. This is the situation and here f n is the function representing [00:11:58] the algorithm and this g of n is the function representing the computational complexity or [00:12:04] representing the pre known function. This is known function if you remember and this is given. [00:12:11] Now, we have T n that should be less than or equal to C of what assumption we are taking [00:12:18] that is n of log of n. So, T n should be less than or equal to floor of log of n. So, that is [00:12:30] now what we have did, we have replaced the or we have expanded this or let me solve this. [00:12:44] by refreshing this. Now, we were given this Tn equal to 2 times plur of n by 2 plus n and we [00:13:12] have guessed because it is looking like merge sort. So, I say that it is worst case computational [00:13:17] complexity is n of log of n. And when we are saying it is worst case, so what basically if [00:13:23] If you remember we were doing f n should be less than or equal to c of g of n that we [00:13:30] were representing. [00:13:31] Now, here what we have to establish t n is less than or equal to c n of log of n. [00:13:50] This is the known function and this is the we have determined. [00:13:53] Now what we are doing, so we know that t n value should be this one. [00:14:00] So we are establishing 2 times c of floor of n by 2 and log of floor of n by 2 plus [00:14:13] n. And because this is the value of tn and it should be less than cn log of n by 2 plus [00:14:20] n because if we remove just this case. [00:14:26] Now, if we break this C n of log of n minus because of log property and later on we establish [00:14:34] this. [00:14:35] So, from the induction what we found that we have started with T n and we have reached [00:14:39] to C of log of n, this indicates that the assumption is correct. [00:14:50] What we assume? [00:14:51] We assume that T n value should be or just forgot about this less than sign, just consider [00:14:56] the equality. [00:14:57] have considered t n equal to c of n of log of n replace the value and solve it then again we are [00:15:04] getting the same value that is c of n of log of n this establishes that what we have assumed is [00:15:10] correct but the thing here is if our initial assumption is not correct then result will [00:15:31] change, then result will change. If our assumption is not correct, then result will obviously change. [00:15:44] Similarly, the next method that is also known as iterative method. So, [00:15:49] I am not giving more time in this, just know it because for those who are interested in this, [00:15:55] how this actually solve our things, because there are some examples where our induction methods [00:16:00] does not work. So, just this is a reference example. Yes, there is a possibility of solving [00:16:07] a recursion, but we have to guess the solution. Now, the next one is recurrence tree method or [00:16:16] iterative method. And if you remember, while solving most of the divide and conquer approach, [00:16:22] we were forming a tree like structure that looks like what here we are witnessing, [00:16:27] that is n, n by b, n by b and so on. So, this was how the structure was looking like. [00:16:37] For the same problem what we get, we get that there is a recurrence tree and this tree is [00:16:48] appearing for how long for log of n times because what we are doing n, n by 2, n by 4, n by 8. So, [00:16:57] this series is nothing but this is a series of log of n. So, this tree will go for log of n time [00:17:04] and for how many element, n element. So, computational complexity is n of log of n. [00:17:09] So, this is how we can see in each iteration there are n, n, n, n number because we are [00:17:16] not removing any number and it is going to a log of n. So, ultimately it will be tends [00:17:23] appears to be a n of log of n solution so for any so recurrence tree is pretty easy and if you [00:17:29] understand the problem or you if you enable to capture the recurrence relation or you capture [00:17:36] the structure of the algorithm that is look and and you identify the recurrence relation then you [00:17:40] can use a recurrence tree as well but with series it could fall like log series we know okay in [00:17:46] somewhere it could be something else. So, how you will estimate that is challenging. [00:17:53] So, these are the two simple examples for recurrence tree and [00:17:59] substitution method. Now the interesting one is master's theorem. So, a recurrence relation of [00:18:05] form tn equal to a tn by b plus f of n can be solved by the master's theorem given a is greater [00:18:13] than or equal to 1 and b should be always greater than 1 because if b is not greater than 1 then we [00:18:20] will never do a convergence okay now whenever this type of problem is given okay without being [00:18:34] directly jumping to the cases i'm writing one interesting aspect a problem of form tn [00:18:52] equal to or a you can write not to a of p of n by b plus f of n and this function should [00:19:08] be asymptotically positive function this fn should be a positive function and also asymptotic [00:19:26] Now, and we have to also say that a should be greater than 1, b should be greater than [00:19:38] 1. [00:19:39] If we find all three, then immediately calculate, this is a very important, immediately calculate [00:19:52] n to the power log, a should be this b, a. [00:20:01] So we will get some value. [00:20:06] Let us say we are getting n to the power x. Then compare this with f of n. Let us say it is [00:20:14] n to the power y. Let us say f n or we can say that n of x is compared against n of y. [00:20:22] So, what could be the policy? What could be the possibilities? In comparison, [00:20:29] then what are the possibilities? What are the possibilities? Either n of x is equivalent [00:20:56] to n of y, equal case, either n of x is greater than n of y. So what we have to do n of x [00:21:06] minus some epsilon makes both them equal. Then there could be case n of x is less than [00:21:13] n of y. So what we will do, we will add something epsilon so that we can obtain n of y. So these [00:21:20] are the three cases or the three possibility. Whenever we have a problem like this and we [00:21:25] find a is greater than 1, b is greater than 1, fn is asymptotically positive function, [00:21:31] then immediately calculate n to the power log base b. This is important. Whenever you [00:21:37] encounter a problem, you find it is holding correctness as per the requirement, then we [00:21:42] have to immediately estimate n to the power log base ba. And if it is equivalent to fn, [00:21:49] then it is called as the case number 2. Here this is the case. That is fn equal to n to the power [00:22:00] log. I am not talking about theta, omega and other notations. That we will discuss separately. [00:22:06] But that we have already discussed. But usually if you say this is theta, so theta omega and all [00:22:20] all those stuff we are knowing, but this is case number 2. This is case number 2. And [00:22:27] here we are having some epsilon should be greater than 1, not greater than 0. Okay. [00:22:34] And C should be less than 1. C will consider in the third case. Now, the second case is [00:22:39] that when we have to reduce something, reduce something to equate, if you remember this, [00:22:46] i was reducing something to make the things equal then it is case number one and [00:22:55] third case when we are adding something so that is case number three so equality case if we found [00:23:06] that fn is equivalent to n to the power log of base ba so computational complexity will be n to [00:23:14] the power log of base ba log of n. Clear? So just remember this, we will calculate. [00:23:20] Then if we are reducing something, then we will consider that n to the power log of base [00:23:25] ba. If we are adding something, then it will be f of n only. And here, apart from doing [00:23:35] this, there is one more thing that we have to a, we know f n by b, we can do and it should [00:23:42] be less than c of f of n for a larger n, then this holds. So, this is an extra thing that [00:23:48] we have to do when we are in case number 3. So, one by one we will see how these cases [00:23:54] arise and what are the computational complexities. Just remember, so if it is case 2, we will [00:24:00] go n of, we will go n to the power log base ba log of n. If it is case 1, we will go n [00:24:08] to the power log of base ba. If it is case 3, we will go f of n. So, in a different way [00:24:25] if you think, since here we are reducing something. So, maximum one is what? This one. Here we [00:24:31] are adding something. The maximum one is what? f of n. So, that could be the computational [00:24:36] complexity. Now, here we have one interesting aspect. If you see tn equal to 9 tn by 3 plus [00:24:45] n. So, what I get a equal to 9, b equal to 3 and f n equal to n that is obviously a [00:24:57] function asymptotically positive function. Now, estimate n to the power log of base b a. [00:25:07] So, that is nothing but n to the power log of base b 9. So, what we will get n square [00:25:13] and if we compare with fn, so fn is n, so what we will do, n to the power 2 minus epsilon will be [00:25:23] make this equivalent to n to the power 1. And when we are doing a subtraction, then we are in the [00:25:29] first case and it says that the computational complexity will be order of n to the power log [00:25:37] of base B. So that is big O of n square. So do not bother about big O, the computational [00:25:51] complexity will follow the order of n square. [00:25:54] Similarly, I solve one more problem. Here we have 3t n by 2 plus n square. So again [00:26:05] you see fn is equal to n square, a equal to 3, b equal to 2. So immediately we calculate [00:26:13] log of base b a so that is n to the power log of 2 3 so that is nothing but n to the power [00:26:22] 1.58 and here if you see it is n square so what we have to basically do 1.58 plus from epsilon to [00:26:33] make it equivalent to n square so we are in case number 3 so here we have to also check what a of [00:26:41] f of n by b should be less than c f of n. So, a is how much? b f of f of n by b, n by [00:27:00] 2 should be less than c of f of n that is n square. 3 into n square by 4 should be less [00:27:13] if I assume c equal to 1 n square. So, it is 3 by 4. So, the condition holds. [00:27:20] Now, we can easily say that the computational complexity is of order [00:27:26] theta of f is f n that is n square. So, likewise, here are some problem, I will solve the problem, [00:27:34] then I will take the queries one by one. So, first problem if I solve, so f n is n, [00:27:42] a is 3, b is 5, n to the power log of b is 5, 3. So, probably its value is 0, 0.68. So, [00:28:17] what we will get n to the power 0.68. And if you compare with this, so what we have to do, [00:28:24] we have to do some addition. So, here we are in the case number 3 and there is a specialized [00:28:31] condition that is a of f of n by b should be less than c of f of n. So, a of f of n [00:28:44] is just n, so it will be 3 n by 5. If we just consider c1, it is of course true. So, we [00:28:55] are in the case number 3 and for this the computational complexity is theta of n. [00:29:02] Similarly for this problem, a is 2, b is 2, so when we calculate n to the power log base [00:29:19] pa, what we will get n to the power log 2, 2, so that is n to the power 1 and if we compare [00:29:34] n, if we compare n to the power 1 with n, then of course both are equal. [00:29:42] So, we are in case number 2 and that says the computational complexity will be theta [00:29:50] of n to the power log base ba log of n. So, that is nothing but theta of n log n. And [00:30:01] if you remember, this is the recurrence relation representing the merge sort. So, just separating [00:30:13] these two. Similarly, if I solve for the third one, so let us check how it is behaving. [00:30:41] Now a equal to 2, b equal to 2 and theta of n is 1. So n to the power log base b a that [00:30:55] is 2 and 2. So n, so what we have to do 1 and here it is n to the power 0 f n. For comparing [00:31:05] we have to do a subtraction. So we are in case number 1 and case number 1 says that [00:31:12] the computational complexity will be theta of theta of n to the power log because we are reducing b [00:31:31] a what it will be theta big o of n. If I do for other cases so that that I will do later on. [00:31:42] let me take your doubts if you have the bench uh i have allowed your mic the bench [00:32:12] are you there hello anupam i have allowed your mic [00:32:42] yes yes i can hear you be louder hello yeah so yes i can hear like yes yes uh does this master [00:32:55] Param, give you any idea about the space complexity like? [00:33:00] No, from recurrence relation, it is already hidden. So, what is the space complexity, [00:33:08] we are not bothering about in the recurrence relation, that you have to explicitly see. [00:33:12] But whenever we are talking about a recurrence relation, then you are talking specifically [00:33:17] specifically about that Fn, that the function that represents the algorithm. So, here there [00:33:23] will be no rule of space complexity i think there is some issue at the mic and any other query [00:33:52] yes yes you are audible so sir can you explain that case number two and case number three sir [00:33:58] specifically case number three could enable to understand well okay so what we are doing [00:34:05] whenever we had a problem of this form we will immediately calculate what n to [00:34:09] n to the power log of base ba okay and let's say we are getting something n to the power 1.58 [00:34:17] and our fn is n square so what we have to do we have to add something when we will add something [00:34:22] then the case will be case number three i hope up till this it is clear here we are doing what [00:34:30] this power plus epsilon and there is one attached one more attached thing with the case number three [00:34:37] is we have to also check a f of n by b is holding for this one where c should be less [00:34:46] than 1. C should be less than 1. If these two case holds, then we can immediately declare [00:34:52] the computational complexity as theta of f of n, that is this f n. Because this is larger, [00:34:59] because we are adding something, so which is larger, f n is larger, so it will represent [00:35:03] computational complexity but to to directly so we have to prove this situation additional situation [00:35:13] getting okay so whenever we are adding then it will be like case number three and whenever we [00:35:19] are subtracting that will be case number one right yes yes yes and we know that when we are subtracting [00:35:24] then which one is the highest and to the power log base b one is highest so that is coming in [00:35:30] the complexity if we are adding then which one is highest fn is highest then then it is [00:35:35] playing the role of computational complexity so these two cases are clear when it is equal [00:35:40] then we are doing what we are taking n to the power log base ba and adding one more term that [00:35:45] is log of n i guess now you can remember the cases when we are subtracting which is large [00:35:52] and to the power log base ba is large so that is the complexity when we are adding fn is large that [00:35:57] is the complexity when both are equal so we can take anything n to the power log base ba and add [00:36:03] one extra term that is log of n okay but in case number three we have to also prove this for us [00:36:09] let's see less than one if this is established then we can say we are good to go understood sir [00:36:19] thank you yeah sure of kumar pande you will be the next good morning sir good morning yes sir [00:36:33] basically i just want to ask is the master theory uh theorem giving the average case complexity [00:36:39] not the worst case again i'm saying that we already have covered theta big omega and so all [00:36:48] are somewhere equivalent so we can say that it is uh primarily giving the computational complexity [00:36:55] order so you can write accordingly first case every case another so yeah if that's the case [00:37:01] so the another thing just i want to ask what is the significance of right if you look at the case [00:37:06] one case 2 or case 3 you have written f of n is equal to big o of n to the power log of b by a [00:37:12] minus epsilon and where on the case 2 it is like theta and on the case 3 it is omega so what does [00:37:19] this specify yes a very good question so here if i am reducing something from so what i am targeting [00:37:27] the maximum possible value of fn would be what this one here we are adding something so what we [00:37:33] are targeting the minimum possible value of n to the power log base ba because we are reaching to [00:37:38] the minimum and that epsilon is added. So, you can say it is representing a best case, [00:37:43] it is representing a worst case, it is representing a average case. So, that is a representing aspect [00:37:49] but we are we have to much more bother about the order. Getting why I am saying it is big [00:37:58] go because we are reducing something so this is maximum thing that we can get and this is the [00:38:05] minimum thing because we are adding something over it and in between will be the average case [00:38:09] so this is worst best and average case so so that representation it is reflecting getting [00:38:16] yeah yeah so i'll tell so basically what i understand from this is that something that [00:38:23] we have figured out like when we have calculated analog b by a so it is like we have got something [00:38:29] for the case one i am speaking about so we have got the values that is something lesser than the [00:38:34] f of n so basically we scale down that f of n okay to bring it equivalent to this and basically [00:38:40] the original f of n was bigger than that so basically we can consider okay this was the [00:38:44] like the higher the top boundary is now far so that is the worst case the top boundary is lower [00:38:51] so that is the best case so so that is the thing if you remember the graph so basically so basically [00:38:57] sir it would be like n log b by a uh less than equal to f of n that is the case it is representing [00:39:02] in the case yes yes yes yes okay okay so answer uh for the other two methods that you have spoke [00:39:08] about like substitution and recurrence i think will they give the theta notation or the like big [00:39:14] connotation actually every time we are targeting what order of computational complex it is theta [00:39:21] omega or that is the other aspect but we determine the order here order this one is [00:39:25] so so there you can say whatever the computational complexity so they are a little bit you can say [00:39:33] not to the mark or exactly they are not calculating but that is up to you how you [00:39:37] are demonstrating the algorithm okay so so basically the last final question about this [00:39:42] would be like as we have uh understood the asymptotic notation so basically these three [00:39:48] make a huge difference as we have as we have studied because yeah boundary line so basically [00:39:53] i just want to know this master theorem would be like if someone precisely uh get to the point that [00:39:59] okay master theorem would represent the theta notation like average case yeah yeah okay if [00:40:05] something is theta then it is obviously a big one big omega if you remember the theorem we have [00:40:11] approved yeah yeah yeah okay sir thank you sir that was nice hello you will be the next good [00:40:26] morning good morning uh sir this my question with respect to the previous substitution method [00:40:32] where you mentioned that we have to make a guess as a very first statement right yes so uh is there [00:40:37] is any uh list of a few inputs from you like a key for us that what could be the possible guesses in [00:40:44] your experience so that because you also said that did this guess part comes so the the algorithm [00:40:53] complexity that we have witnessed so far is n square n log n and uh n of log of n these four [00:41:01] i i guess we have seen and there was a brute force variant of that one um maximum severity [00:41:07] was n cube so among all three we will try to guess this five one two three four five [00:41:14] Most of the cases this is applicable, so if there is some changes that we have to but [00:41:19] most of the cases these these five computational complexity are usually very common n square [00:41:24] and log n, n log n and n cube, so these are the common computational complexity we will [00:41:30] see throughout the algorithms, so that type of guess you can make, so in that sense you [00:41:36] have to solve around all these five and then then see where it perfectly fits actually. [00:41:41] mere is perfect and also we have some idea about around the recurrence relation of merge sort and [00:41:46] other so that's it is uh n of log of n so that type of guess you can make okay okay my second [00:41:54] question is sir with respect to the master theorem actually okay yeah so in this case uh the when you [00:42:03] have the uh you can say case two right so it actually has this different you can say theta [00:42:09] notation right so i think someone was also sort of was also asking around it so was this make [00:42:15] any difference uh when we look around uh the solution aspect that uh the first case we are [00:42:21] having we go and then we are going with theta and then the last we are going with the different one [00:42:27] just to confirm okay so if you just forget all these three notations these symbols so we are [00:42:34] are bothering mainly about the order here order is this one here order is this one and why we [00:42:39] are applying so we go because we are getting a value that is more than fn so what we are doing [00:42:44] the gn is greater than fn then it is we go here we are getting a value less than fn so gn is um [00:42:52] sorry gn is less than fn so we are in the case of v go mega so that's why these symbols are coming [00:42:59] and here it is equivalent so theta notation we are applying here we are getting a function that [00:43:06] is greater than fn so we are theta less than fn omega and in between theta sure one of the last [00:43:16] summary questions if where this master talent usually mean occur in terms of a real-time [00:43:21] example like any kind of business use cases that is so if you have a computer algorithm of this [00:43:27] form okay that is recursively calling like this one so what is the computational complexity of [00:43:32] such algorithm you can say okay this this by master theorem i will solve and get back the [00:43:37] computation because directly looking to this a n t n by b plus f n we cannot see how your algorithm [00:43:42] will behave in real scenario unless you have a this uh n of log of n or n square or n cube then [00:43:49] only we can come and keep this algorithm behavior is likewise otherwise you have to what we can [00:43:54] convey from the recurrence nothing so any any previous uh like in had example from you like [00:44:01] while solving search algorithm this this pattern has came so that that can be relatable [00:44:07] in a real example already i have stated in merge sort binary search instructions okay okay okay [00:44:15] i just thought of having a real example that's a real example what you can do for master theorem [00:44:21] for algorithm there may be a real example but for most of them i don't think okay okay [00:44:30] hello bikesh you will be the next hello bikesh are you there yes yes hello yes yes yes good morning [00:44:57] sir uh while solving for third cases you have taken c equal to one but in here we have this [00:45:05] condition yeah here if i put uh 3.5 by 4 so i'm taking a you can say boundary case you just take [00:45:15] 3.5 by 4 so that is applicable c is less than no everywhere but i when i wherever i solve if you [00:45:21] apply that then that is applicable in some of the cases if c you have to take a greater value then [00:45:26] the master serum cannot be applied there okay okay okay and sir i have one more question [00:45:32] regarding the recurrence components like the base case recursive case and initial conditions okay so [00:45:39] while solving these equations we didn't consider these three components like we we have to have [00:45:47] some base cases and then we have to initialize the conditions in order to come up with the [00:45:54] best case or worst case see this example i i hope your doubt will be solved this is the recurrence [00:46:00] relation for n greater than 1 and this is for n equal to 1. So, this becomes the base [00:46:06] case. So, all these recurrence relation are this recursive step only, not the base condition [00:46:10] and other. But in a recurrence, these are already there. We are just solving or talking [00:46:16] about this portion. Okay. This recurrence relation is that will reoccur again and again. [00:46:25] And in a recursion, there are three things, that is base case, recursive case and initial condition. [00:46:32] So, we are primarily taking the recursive case and trying to estimate its computational complexity. [00:46:39] Okay. And what about initial conditions? [00:46:43] So, initial condition, here initial condition is what? [00:46:47] When n equal to 1, we are taking c equal to, that is exactly c. [00:46:52] And there might be a situation that if you remember n 0 greater than 6, then it was applicable. [00:46:58] So, for what about these 5 terms? [00:47:00] So, that we have to put at the initial condition. [00:47:03] Okay, when it is n is less than 5, then we have to apply different function. [00:47:08] And when n is greater than 5, then we have to apply this recursive function. [00:47:12] That type of situation it is. [00:47:14] Right now, I am not recalling any example that I will show to you. [00:47:19] but but the thing is base case is that the terminating case and there might be situation [00:47:26] that a function fn okay let me take one example i will try i am taking one function fn equal to [00:47:33] n minus 6 and we know that for value less than 6 or 6 this will become 0 so when we put n greater [00:47:45] than 7, then we can apply any recurrence relation. For n greater than 0 and less than 7, we will [00:47:56] apply some other case and there will be a base case that when n equal to 1, then we will [00:48:01] stop. So this could be the three situations. This is initialization. For few values, we [00:48:06] have to do something. For most of the value, we have to do a recursive call and there will [00:48:11] be a base condition okay but this initial state uh rarely occur in few of the problem so so sir [00:48:19] base case is to converge the function so that we have this is the terminating point where we will [00:48:24] stop yeah so basically we are converging to a point yeah toward a point that is the base condition [00:48:31] that is the stopping point okay and and uh for master theorem uh we we have set of criterias [00:48:40] and in there do we consider these uh these components the recurrence components while [00:48:46] solving the equation yeah yeah yeah because base condition is the last condition and our algorithm [00:48:54] complexity depends upon how your recursive structure behave [00:49:00] yep yeah okay sir thank you so i'm taking a short break and then we will resume and other [00:49:10] query we will solve in the next time after solving some of the real examples okay just taking a few [00:49:17] minute break okay so um i will take i guess two three doubts are there so i will take it and then [00:57:02] then proceed sir he will be the next and i'll learn your mic uh sir good morning good morning [00:57:15] yes sir so as we understand the whole aim is to get the n log b a as close as to function fn [00:57:23] yes yes yes that is a great point either add epsilon subtract epsilon or is it either almost [00:57:30] equivalent so it will fall either in case one two and three yes yes yes this big o theta and big [00:57:38] omega are the same notations which we had learned earlier which is on the upper bound lower bound [00:57:43] and on the yes yes yes yes yes so it is equivalent to that correct yes yes thank you that was the [00:57:49] the only question i have yeah mohit kumar you will be the next just just a minute yeah yes [00:58:01] please ask the question yeah good morning sir good morning actually you said the c value should [00:58:10] be less than one yes but it can be negative also it can be zero also it should be in between zero [00:58:18] and one okay should not be zero yeah negative value is not possible if it is negative so if [00:58:24] you see if this is negative then what it is basically happening this n by b thing is not [00:58:30] reducing the problem size okay if you know well form recursion what we were talking about so if [00:58:36] this is happening then this is not reducing the problem size and your recurrence relation will [00:58:40] never converge [00:58:41] strictly between 0 and 1 [00:58:45] I mean [00:58:45] less than or equality or greater than [00:58:49] equality will not be there [00:58:50] strictly [00:58:51] I guess we are good to go [00:58:57] yeah sir we are good to go [00:58:59] but sorry sir [00:59:01] I have one doubt [00:59:02] yeah [00:59:03] so sir if we see [00:59:07] that master theorem [00:59:09] so there is the three conditions [00:59:11] If we put that Marge-Shot complexity, so as the Marge-Shot complexity is n log n for the best case, Orr's case and average case is same. [00:59:21] So, Master theorem will justify that one. [00:59:25] Means with the Master theorem, we can calculate that one, right? [00:59:29] Yes, yes, yes. [00:59:30] And next question is, if there is no recursion in algorithm, suppose not all algorithms have that recursive problem, right? [00:59:39] Yes, yes, yes. [00:59:39] So, how, means, there we will not put that master theorem, it is only for the recursive [00:59:46] problem. [00:59:47] This is only for recursive problem and we will discuss where this master theorem cannot [00:59:51] be applied. [00:59:52] Okay. [00:59:53] And already we have estimated n square others directly from the algorithm seeing the loops [00:59:57] and other aspects. [00:59:58] Okay, sir. [00:59:59] Thank you so much. [01:00:00] Yes, sir. [01:00:01] We are good to go. [01:00:06] Yeah, yeah. [01:00:07] So, we were solving these, some of these examples. [01:00:17] Okay. [01:00:18] So, whenever we get a recurrence relation like this, eventually we will try to calculate [01:00:24] n to the power log base ba as last person was saying and we will try to make it as equivalent [01:00:30] to f of n, making that could be what, we will be adding something or reducing something [01:00:36] as well. [01:00:37] So, now let us talk about these cases, so here is a problem and this is n by log of [01:00:45] n. So, here what happened, a is 2, b is 2, f n is n of log of n. Now, we will calculate [01:01:01] n to the power log base b a, that what is the value log of 2, 2, so that is n to the [01:01:13] power 1. So, what this indicate if we add some epsilon, then we will get n to the power [01:01:19] 1 plus some x because this is log n. But what is the problem? The problem is this epsilon is not [01:01:28] fixed because we know that the logarithmic behavior is different. So, whatever we are [01:01:33] putting as n plus x will not fixed and that is the problem. In master's theorem, the assumption [01:01:40] of the epsilon is remain fixed, not fixed. This is not fixed. Remain fixed throughout. [01:01:55] And this epsilon is not fixed because we are dealing with the term that is logarithmic term. [01:02:00] So, thus we cannot apply master's theorem in this in again the next problem this, [01:02:08] though it appears that we have to add something. So, we are in the case number 3. [01:02:13] Now, look at one situation. One situation is that we are adding epsilon to achieve this. [01:02:19] Now, why that case a of f of n by b should be less than c of f of n. So, let us check [01:02:29] whether it is happening or not. So, a is what 2 f of n by 2 should be less than c of f of [01:02:38] n. So, what is n value? So, that is 2 into n by 2 into log of n by 2 should be less than [01:02:52] c any smaller value n of log of n. So, if you check this is n of log of n by 2 or we can say [01:03:05] that n of log of 2 minus sign equals n and if we take any value n of obviously this relation holds. [01:03:17] But this epsilon should vary, this epsilon should change its behavior or vary value. [01:03:26] So, what we can say, we can say that for those function where estimating epsilon is [01:03:35] is, you can say floated. Floated means that they can change its behavior, we can never [01:03:41] apply. So, when f n is logarithmic, when f n is sinusoidal, when f n is a function of [01:03:50] 2 to the power n or factorial n, so there we cannot apply the master's theorem. So, [01:03:56] this is a drawback of master's theorem, where we cannot establish a fixed value of epsilon. [01:04:01] So, in that case, we can never apply a master's theorem. So, this is you can say drawback [01:04:07] of master's theorem or whatever it is. So, we will solve all these problem one by one, [01:04:13] but let us see if, so this is the three cases. These are the three cases explanation. If [01:04:19] cost of solving the sub problem at each label increase by certain factor that is epsilon. [01:04:26] So we are in case number 3, if solve each step is nearly equal to f n and in each step [01:04:33] decrease by certain factor, then we are in case number 1, this is case number 2 and this [01:04:39] is case number 3. [01:04:41] Now where this cannot be applied, when T n is not non-monotone like sin x 2 to the power [01:04:47] x or if the a is not a constant or a is less than 1 or logarithmic even we cannot apply. [01:04:53] we will see how logarithmic things can be solved but there we cannot apply directly the master's [01:04:59] theorem okay so here are some examples okay so if you see log term don't apply master theorem log [01:05:09] term don't apply master theorem but order terms are given then we where we can easily apply so [01:05:14] here it is n square plus n so we have to reduce something we are in case number one and complexity [01:05:23] will be order of n square. Here a is 1 that is greater than or equal to n and b should [01:05:36] be, b is what? b is 3 by 2 and a is 1. Then also we can easily apply because this is f [01:05:43] n is, you can assume n to the power 0. Here also we can apply. So if you see, if you remember [01:05:49] this is the expression for stress. So, we can calculate n to the power log base b a. [01:06:02] So, that is nothing I am doing for this. n to the power log of base b is what? 2, 7 that [01:06:10] is n to the power 2.81 if you calculate. If it was 8 then it is 3 otherwise it is 2.81. [01:06:17] Now, n to the power 2.81 minus epsilon will give you n square. So, minus epsilon case [01:06:25] number 1 and in that case, the computational complexity is theta of n to the power log [01:06:31] base ba that is 2.81. And we know the computational complexity I was claiming at that time is [01:06:37] n to the power 2.81. So, this was the stresses expression and we are getting the computational [01:06:42] complexity like this one. And this is for normal multiplication. Each problem is divided into 8 [01:06:49] sub problem. If you solve here, then what we will get? n to the power log 2 8. So, that is n cube. [01:06:58] And if you compare with n square, we are reducing something. So, again, [01:07:02] it is computational complexity is n cube. So, what we are guessing, whatever the problem we have [01:07:10] solved so far or we have understand its computational complexity help data can be [01:07:16] determined by the master theorem. So, there is some you can say conditions where we have to stop [01:07:23] that is whenever we encounter a log term, a sinusoidal term, 2 to the power n term or when [01:07:31] value of a is less than 0 or value of b is less than 0, then master theorem is not applicable. [01:07:37] So, I just request everyone to after this class, I will share the PPTs or I have already [01:07:43] shared. [01:07:44] So, just solve all these problems, just these two are the exceptions. [01:07:52] And here are some other solutions as well. [01:07:54] So, if you go directly, so you can directly go for the case number 2, but this is wrong. [01:07:59] This is also wrong. [01:08:03] Now, let us consider the case, we want to identify the computational complexity of this [01:08:10] recurrence relation that is t n equal to 2t n by 2 n log n. What I am doing t n equal [01:08:20] to 2t n by 2 plus n of log of n. And we know that we cannot apply the master's theorem [01:08:32] here. So, what we have considered we have assumed n equal to 2 to the power m. So, this [01:08:37] is different mechanism of solving. So, if I put here, then what I will get 2t n by 2. [01:08:45] So, 1, 2 is going to subtract. So, 2m minus 1 plus 2m, because it was n log n, log of [01:08:53] base 2. If we solve, then we will get this value. What I just assume, assuming n equal [01:09:02] to 2 to the power m, then what we will get? t of 2 to the power m is equal to 2 into t [01:09:09] of 2 to the power m minus 1 plus 2 to the power m log of 2 to the power m, here base is also [01:09:18] 2. So, we will get this value. Then what I am assuming, t of 2 to the power m as a function [01:09:25] of f of m. Then what will happen? f of m equal to 2 into f of m minus 1 plus m into 2 to the [01:09:34] power m, because we are considering the function. So, here we assume it is a function of f of m. [01:09:44] This is a function of f of m and iteratively solving, we will reach to a situation like this [01:09:50] one. And that is as equivalent to the case of log of n, 1 plus log of n by 2 or this [01:10:00] is n of log square n. So, basically what we are doing, we are just dividing this. So, [01:10:07] it is 2 into 2 times m minus 2 plus m minus 1, 2 to the power m minus 1 plus this one. [01:10:15] And if we go on solving, solving, then ultimately what we will get 2 to the power m f of 0, [01:10:20] 2 to the power m if you take comma then 1 plus 2 plus 3 plus m and this is nothing but 2 to the [01:10:27] power m into f 0 plus m into m plus 1 2 to the power m and what we assume that this 2 to the [01:10:34] power m was nothing but this is n. So, n into f of 0 plus m, m plus 1 by 2 and 2 to the [01:10:54] power m was n. So, if you come up the solution for this, so it look like n into t1 plus n [01:11:04] into log of n 1 plus log of n by 2, that is simply m into m plus 1 by 2 and it will go [01:11:12] to the n to the power log of base 2 m by log square, of course here it is base 2 n. [01:11:18] So this, why I am telling this example, so this is little bit complicated where we were [01:11:25] assuming certain, so this is again a prove by induction. [01:11:37] here we are not assuming anything, we are iteratively solving the things and we are trying to [01:11:41] achieve what could be the behavior of the algorithm after solving. So, these are the few cases where [01:11:49] master's theorem cannot be applied. Just I have written down all the steps, just copy it down and [01:11:58] try to get what I try to convey, everything I have written, just see the part and so here [01:12:03] basically what we are doing, we are every time we are expanding, we are expanding, we are expanding [01:12:08] and ultimately we found that the series is looking like this one. So, this is all about the recursence [01:12:20] and recurrence relation, divide and conquer and other steps. The new part of our things will be [01:12:28] the details about the new thing that is tree. So, the data structure that we have so covered so far [01:12:35] was linear. Now we will talk about non-linear data structure. So, tree is one among them [01:12:45] and next one that we will see that will be graph, that will be graph. So, what is non-linearity [01:12:54] means? The access pattern or the placement of the nodes are done in an hierarchical order [01:13:00] or we cannot sequentially access one variable over other. We cannot sequentially access one [01:13:06] variable over other. So, tree is a non-linear data structure. It is mainly used to represent [01:13:20] data containing a hierarchical relationship. This is important, not linear relationship [01:13:26] between element, table of contents. Example is table of content. Hierarchical means that [01:13:31] one section we are getting multiple subsection then another then we are getting multiple subsection. [01:13:37] So, this is a hierarchy then on the top there are chapter name or unit name and this there [01:13:42] are different chapters and in the chapter there are sections subsections. So, this will form a [01:13:48] hierarchy, it will form a hierarchy. So, this for hierarchical arrangement we are saying that [01:14:00] the tree data structure can be used. And among them, the binary tree is one of the famous. [01:14:06] So binary tree means that if there is a node, and there are two possibilities, [01:14:14] maximum two possibilities. So a binary tree is defined as a finite set of element [01:14:19] called as the node. So these are called as the nodes. These are the nodes in the tree, [01:14:28] such that T tree is empty, that there will be no node. When tree is empty, then there [01:14:32] will be no node. The T contain a distinguished node R called as the root. This node is called [01:14:39] as the R or the root, the first node and these are called as the child node. T1 and T2 are [01:14:45] the child node. So, here it is written, this is root node, these are the child node and [01:14:52] this may be having other nodes and as well. So, these are the subtree hold the property [01:14:59] of the tree itself. These are the subtree hold the property of the tree itself. So, [01:15:04] a node n in a binary tree t can either have 0, 1 or 2 successor or child. So, this is [01:15:12] root and this is a binary tree, this is a binary tree, this is a binary tree. So, 0 [01:15:17] 1 child and 2 child. So, entire arrangement will follow 2, 1 or 0 child. So, every node [01:15:28] n of tree contain a left and a right subtree. This is left subtree and this is right subtree. [01:15:35] Left subtree and right subtree and we will see more property of the tree. So, tree is what [01:15:43] basically the collection of node and edges where the arrangement in a hierarchical and [01:15:49] there will be no loop. So, what is loop means? This is tree, we are keep on drawing and if [01:15:56] we connect these two, then this become a closed boundary or loop and if it is there, then [01:16:01] it is called as the graph. If there is no closed boundary or loop, then it is a tree, [01:16:05] otherwise it is called as a graph. So, here we are seeing the example copies. So, when [01:16:12] one tree directly superimpose over each other, then it is called as the copy. And this EFGS, [01:16:18] though they are having same number of nodes, but they are not copied, they are mirror images. [01:16:23] So, this is one thing. Second thing is that why we are studying tree? Because tree are primarily [01:16:29] used for solving the algebraic expressions like A minus B. So, on the leaf part, we will have the [01:16:38] operant and on the root we will have the operator. So, for this expression we are basically preparing [01:16:45] a expression tree or algebraic expression tree. So, you can see a b minus c d into plus [01:16:52] e and that is further last one is the division, the root, this is called as the root, this [01:16:58] is left child and this is right child. So, we will see some of the things. So, this p [01:17:06] P is also called as parent, ancestor or root, the first node. [01:17:12] And this is also called as left son, left descendant or left child. [01:17:18] And this is called as the right son, right descendant or right child. [01:17:22] And these are the labels. [01:17:24] So this is label 0, here it is written on label 0, label 1, label 2. [01:17:28] So this is label 0, this is label 1, this is label 2, this is label 3. [01:17:33] And the nodes are at same label or called as the siblings. [01:17:35] So these are the siblings, these are the siblings, these are the siblings. [01:17:39] Okay. [01:17:40] And the node that is in the last is called as the leaf node last means that there is [01:17:44] no further sign. [01:17:45] So these, sorry, this, this, this, this fora, this is not this is the leaf node because [01:17:52] there is the leaf node does not have any child leaf node does not have any child leaf node [01:18:04] does not has any child. And left son, right son, left descendant, right descendant, ancestor, [01:18:10] successor, predecessors, there are different terms. So that will be, you will encounter, but [01:18:16] that I will explain one by one as they come. But in general, these are the things. And this is edge [01:18:23] that connects two nodes. So this is node and this is edge. And path is, so from A to D, [01:18:33] the path will be what? A to B, B to C, C to D. So, we will consider vertex by vertex. [01:18:38] So, edge can be named as AB, another edge is BC, another edge is CD. This, this, this [01:18:45] edge. And label you understand. So, root will be always at label 0 and leaf will be always [01:18:51] at the maximum label. And height of the tree is the maximum number of node in any branch [01:18:58] of the tree. So, maximum number of node if you see 1, 2, 3, 4, 5. Excluding root, the height will be [01:19:06] what? 4. So, it is at label 0. So, I hope you people get little bit glimpse about this. So, [01:19:15] in the next class, we will again start with the tree and try to discover some of the properties. [01:19:21] So, there are little interesting trees that we will see, complete tree, complete binary tree, [01:19:26] binary search tree, AVL tree, M way tree, B tree, B plus tree, number of things are lined up. So, [01:19:32] we will try to cover as fast as we can the trees, okay, because algorithm syllabus is quite large, [01:19:39] but do not worry, whatever I will taught will be your portion and what I target, whatever I taught, [01:19:44] you should understand or gain something out of it, okay. So, this tree discussion we are stopping [01:19:49] here. So, those who can do can see some of the lectures online for this, but otherwise do not [01:19:55] worry, we will cover tree in a detailed one. Okay. So, now I am stopping here. If someone [01:19:59] has some query, we will take, otherwise we will close the session. Sir, in chat, Lakshmi [01:20:07] Harika says to explain the master, last master theorem problem again. That was not solved [01:20:16] by the master's theorem. This one. Yeah, that one, last one. Yeah. So, whenever we reach [01:20:24] to a situation that this function, this f of n does not show a uniform behavior, n of [01:20:33] log n will not show a uniform behavior, though we can say that we are in case number 3, because [01:20:42] n to the power 1, when we compare with n to the power 1 plus some x, that x is not fixed. [01:20:50] we cannot take an fixed value or a specific value of epsilon. Then here we cannot directly apply [01:20:58] the master's theorem. So, we come up with a new technique or a new thing that is we have assumed [01:21:05] n as 2 to the power m. Then what we will do? Put n equal to 2 to the power m everywhere. So, [01:21:14] 2, 2 to the power m by 2. So, 2 to the power m minus 1, then here we are getting 2 to the power [01:21:22] m log of base 2, 2 to the power m. So, all the n value is replaced with 2 to the power m. [01:21:29] All the n value is replaced with 2 to the power m. Now, we say t 2 to the power m as a function [01:21:39] of f m 2 for simplicity. t 2 to the power m is a function of f of m. So, now this expression, [01:21:50] whatever we have got will be converted into 2 to the power f m minus 1 plus m 2 to the power m. [01:21:57] Okay, now we are expanding this. We know that f of m is nothing but, f of m is nothing but [01:22:07] 2 into 2 to the power per n. Let me solve separately, just splitting a little bit loss. [01:22:34] So we have problem, just give me a moment, I will do a full screen and solve the entire [01:22:40] problem again. There is some hang in my laptop, just give me a minute. So the problem was [01:25:22] t n equal to 2t n by 2 plus n of log of n. What I assume, because we know that it cannot [01:25:40] be solved by the master cell. So, I say that n is 2 to the power m, I am assuming, assuming. [01:25:46] Now, what I did just put the value t 2 to the power m equal to 2t, 2 to the power m minus [01:25:56] one I hope everyone agree because there is a 2 below. So, it will reduce the power by [01:26:00] 1 plus 2 to the power m log of base 2, 2 to the power m. So, what we will get 2t 2m minus [01:26:12] 1 plus 2m and this is log. So, here obviously, we will get a m. So, now I am considering [01:26:20] t to the power 2m as function of m, as function of m. So, what we can say that fm equal to [01:26:33] 2 f of m minus 1 plus m into 2 to the power m. Now, what I am basically doing, I am expanding [01:26:49] this. So, 2 times, this will be 2 times f of m minus 2 plus m minus 1, 2 to the power [01:27:02] m minus 1. And of course, this is other aspect. So, that is m into 2 to the power m. So, if [01:27:10] we solve then what we will get 4 times f of m minus 2 plus m minus 1, 2 to the power m [01:27:23] plus m into 2 to the power m. If you solve, then we will get this solution. I guess this is [01:27:36] m minus 1, this value. And when it is multiplied with another 2, so 1 power will be reduced. So, [01:27:45] this is removed. Now, if we further solve, so 4 times, then m by 2 will be expanded and other [01:27:52] will remain intact m minus 1 into 2 to the power m plus m into 2 to the power m. So what [01:28:01] we will get here f 2 times f of m minus 3 plus m minus 2, 2 to the power m minus 1. [01:28:10] So if you go on further solving, solving and till last then what the situation we will [01:28:15] get, we will get 2 to the power m till last when we are doing, m is reduced. So 2 to the [01:28:21] power sorry 2 to the power m f of 0 plus 2 to the power m because every time we are getting [01:28:29] 1 plus 2 plus 3 dot dot m. So, what will happen 2 to the power m f of 0 and this will be m [01:28:39] into m plus 1 and 2 to the power m by 2. So, basically we will get 2 to the power m f of [01:28:48] 0 plus m into m plus 1, 2 to the power m minus 1. Now, if we try to get back the value, so [01:29:03] what we will get? 2 to the power m was n. So, what we will get? n into f, 0 will be [01:29:12] what? t of 1 plus n into entire thing. We are replacing what? m with, so this is the [01:29:22] value. So, this means that m is equal to log of n. So, everywhere we are putting log of [01:29:30] n. So, that is n into log of base 2 n log of n plus 1 by 2. So, basically what we will [01:29:43] get n into log of base 2 square. So, this is little bit you can say complicated, just [01:29:50] see this so you will find the things is going on so just solve once it will happen yeah any other [01:29:56] doubt or we are good to close yes sir uh two hand rise rest okay okay just give me those who have [01:30:10] done can leave the class okay we are about to close because i am allowing your mic okay hello [01:30:21] sir sir uh actually uh i have a generic question so let's say i have a given a set of numbers and [01:30:30] i have been asked to sort it and come up with the recurrence relation so depending on the algorithm [01:30:36] i choose i will come up with the recurrence relation right yeah yeah so so what should [01:30:42] be my approach first i will be writing the algorithm and then after writing whether there [01:30:48] is any recursive structure or not if it is there there is a recursive structure then we will try to [01:30:53] identify the hidden recurrence relation and then that hidden recurrence relation can be solved by [01:30:58] the master theorem yeah so so how that recurrence relationship will be derived in terms of function [01:31:06] like we we have t of n equal to two uh t of n by two plus some so that that recurrence relation [01:31:15] we know that a problem is divided into two sub problems okay of equal size so it is 2pn by 2 [01:31:22] and while for merging we need what order of n or n square so likewise you can form a recurrence [01:31:29] relation yes okay but but since you have already explained all these recurrence relations so [01:31:37] i assume that recurrence relation will be given uh yes if it is it is not uh what i have taught [01:31:45] it will be given but for a real world problem when we are making an algorithm then you have to think [01:31:51] how your algorithm is behaving okay okay fine yeah okay thank you sir anujay i am allowing your mic [01:32:08] just to add on to the biggest question so when you say real world so does it like if i'm having [01:32:17] my one of the algorithm where it's a multiple iterations are going on yeah so does it fall [01:32:25] with the category where the recurrence relationship can be seen across in your algorithm if you see [01:32:30] the same function is calling again and again again and again again so there is a chance that there [01:32:35] holds a recurrence relation okay so try to identify what type of recurrence relation it is [01:32:40] then only you can apply master theorem and other thing whatever you want right so coming to the [01:32:46] same question sir so if in case my my my algorithm has been written as in class where i have [01:32:51] you can say a few multiple we can say few independent functions which are being enabled [01:32:58] as a part of [01:33:00] global argument [01:33:02] and also there are a few which are [01:33:04] actually the stateful argument [01:33:06] like within the class it has to be always there [01:33:08] like a mandate one. [01:33:10] So in that notion there will be a few [01:33:12] I can say [01:33:14] a few portion will come up with a recurrence [01:33:16] a few portion may not [01:33:18] come in a recurrence portion [01:33:20] like an iteration. So [01:33:22] can we say that the whole algorithm [01:33:24] which we are writing should fall [01:33:26] in the same way that yeah it will be covering okay in all the in master's theorem if you see [01:33:31] the structure now one was t n equal to 2 t n by 2 and f n was there so f n is for non-recursive part [01:33:39] and this t n plus 2 n by 2 whatever it is it is for recursive part so same structure is holding [01:33:45] both in that manner you can you can come up with a problem if your non-recursive part is more [01:33:52] you can say time consuming than the recursive part then obviously it will dominate as we [01:33:56] have seen in the three cases so likewise you can make okay so we have to find uh structurally that [01:34:01] which is dominating factor the dominating part will be the complexity that already we know [01:34:07] okay okay okay thank you thank you and just when uh when assuming partly you're trying to tell [01:34:12] about the tree side so there was a structure where you have the leaf which is uh which is actually [01:34:20] a part of the last sibling and it's not having any sibling in the figure i mean the last figure [01:34:27] if you see just before this yeah yeah yeah this one if you see the last leaf so the last leaf [01:34:35] yeah so the the last leaf which is present yeah yeah yeah so this one it doesn't like [01:34:41] it has to be have um i can say a marginal sibling on the left on the right too isn't it [01:34:48] the correct way we assume because the because height if you see the height it will go till the [01:34:53] last right yeah in this case so is it a correct uh position or i'm just assuming it's a no no it [01:34:59] is correct so because maybe possible so this tree is a maybe the resultant of multiple deletion as [01:35:04] well so earlier there was having some sibling but it is now removed okay because if you see yeah so [01:35:12] So if we see, okay, so we can say that these such kind of tree, sorry, such kind of height [01:35:17] will also determine without any, without any right siblings also, right? [01:35:21] Yes, yes, yes, yes. [01:35:22] Oh, okay. [01:35:23] Okay. [01:35:25] I mean, okay, so I think when you explain that will help more in the next class, we [01:35:30] will start from the beginning for the trees, yeah. [01:35:33] Okay, okay. [01:35:33] Thank you so much. [01:35:34] Thank you. [01:35:36] Okay. [01:35:36] Thank you, everyone. [01:35:37] Thank you, Sanayatani for your effort. [01:35:41] Sayanthani, sir. [01:35:44] What's your name? [01:35:45] Sayanthani. [01:35:46] Yeah. [01:35:48] So sorry for recalling different names. [01:35:51] No problem, sir. [01:35:53] Thanks to you, sir, for this wonderful session. [01:35:56] Thank you very much.