So, yesterday we have started discussion on insertion sort and figure out that the computational complexity on the insertion sort was order of n square and that is for the worst case and we identified that when array is already sorted though so number of comparison will be reduced and number of swap will be also reduced. If the array is reversed, that is sorted in decreasing order and we want in ascending order or increasing order, then in that case, the complexity will be increased and we need to go for maximum number of swap as well as comparisons. So, worst case time complexity of quicksort is order of n square. And then we have seen this simple Python implementation. Again, there is no bound over implementation. You can go with Python C, C++ where you are comfortable. So, the algorithm comprises two loop, that is one loop inside loop and we have already discussed that. If a situation is loop inside loop, then most of the chances the computational complex complexity will touch order of n square. Okay. Now here there are two loops running. So we are starting with the second position and then comparing with the previous one, then third comparing with the second and first, fourth comparing with the third, second and first and so on. So this thing will continue. Okay. And we have also seen that there was no cost that were opposed on the comment as they were not executed during runtime so but for clarity we have written okay and we identified that how many times each step will run and among them we also identified that the step of loop or the step of comparison will definitely impose the high order complexity or the cost C1 and the cost C4 will be maximum among all the costs that we have considered or we can say that even C4 will be much much greater than C1 which is further much greater than all other costs. Why? Because C4 has two comparisons to be performed that is why j is greater than zero and current element less than a of j's these two comparison and in here in this for loop we have to perform only one comparison okay sir sorry to interrupt but some of them are saying that they have a class from 9 30. So, we will close at 9.30, no worries. So, this was the you can say fn or tn, that is the function best representing the algorithmic structure and we identified this f of n is equal to a n square plus bn plus c. So, here this is a quadratic expression and that primarily imposes a computational complexity of order of n square if this term a is a positive thing, if this is a positive. So, I hope till here you people have understand the concept of insertion sort. We have also seen some examples and this is how we can determine the fn that best represents the insertion sort okay implementation wise this is the simplest algorithm okay when we start divide and conquer that is after this asymptotic analysis so their implementation may be little bit tricky so now the next thing that we will discuss is very interesting and if you remember the class one example where we were saying making burger is not a algorithm so this three step will prove okay so now to prove an algorithm correctness loop invariance variance is introduced loop invariance is introduced so what is loop invariance so it is said that if so there is one statement if i say for this the the order of the element or you can say that the property of the algorithm or we can say that the output of the algorithm will not be affected by the loop. So this means that loop will not change the output or there should not be any impact on the actual behavior of the algorithm while performing the different while different loops are running in the algorithm. So here it is, this is called loop invariance. So there are three conditions. It says that the condition hold before the initial iteration of the loop, that is the initialization. Maintenance says if the condition is true before the loop iteration, it will persist before the subsequent iteration. So let us say I had a for loop that is starting from i equal to 1 and will go to i equal to 10. So what it says that before beginning of this algorithm, the condition should hold. What is condition? I will tell later on. So while let us say I am at i equal to 5, then also the condition should hold. And when i equal to 10 or last step, then we will get the output. Upon conclusion of the for loop, such invariance furnaces an important feature demonstrating the correctness of algorithm. So what I want to say, initialization, if you remember in case of insertion sort, we were using, we were starting with the second index. and we have initializes first index as key. And we know that single entry is always sorted, single element always sorted, single element is always sorted. So, this means that even before the starting of the algorithm, the initialization also hold the sorting nature of the algorithm. Now, let us say we are in iteration or step 4. So, what we found? The entry that is first, second, third, fourth are sorted. Irrespective of what elements are present here, but these are already sorted when these steps are complete. Some steps are complete. This means that after step 3, 3 elements are sorted. After step 2, 2 elements are sorted. after step 6, 6 elements are sorted. This means that the property of the algorithm is still maintained even the loop is not fully executed. So, this means that this condition is called as the maintenance. This condition is called as the maintenance condition. Third condition is called as the termination condition where after full execution of the loop, we will get the sorted result. So, this if any algorithm hold all three property, that is initialization, maintenance and termination, then we can say that that algorithm is correct. So, this correctness is verified with the help of the condition that is called as the loop invariant. That is called as the loop invariant and this loop invariant or loop invariance is a famous question or a famous mechanism to check whether an algorithm is correct or not. So let us do with an example. Now let us see how insertion sort operate. Okay. And let us look how these characteristics related to the insertion sort. So we had an array having the element 2, 4, 3, 6, 8, 9, and we have to apply loop invariance insertion sort. So we were having array. Now we are going for the first thing that is initialization check. So we initiate the insertion sort by demonstrating the validity of the loop invariant at onset of initial iteration where i equal to in this case the subarray array 1 that is single element comprises only one element and ARR1 which is essentially the original element in the array 1. Furthermore, it is evident that the sub-arrays inherently sorted affirmating the preservation of the loop invariance. So the story what I have tell is written here. The first single element sorted. Second thing is that where iteration loop invariant should be maintained. The operation of the for loop involves shifting the element so forth one position at right until it identifies the correct position. Subsequently, the insertion of value arif ith element or fourth, third, sixth, seventh, the sub portion is sorted. And last one, it will same say that after completion of the entire execution, we will get a sorted array ARR. Now I hope you people get the glimpse of the loop invariance. Loop invariance says the behavior or the property of the algorithm will not hamper irrespective of the algorithm requirement. So for example, the requirement for the algorithm of the insertion sort was the element should be sorted in each iteration and that is being maintained by the insertion sort in the maintenance space and lastly the final output we are getting. So I hope the condition is clear. So for example, if we talk about the linear search, so in linear search, what is our target? Our target was to identify a key. So initially we started with the key value. from index number one okay so at that time we hadn't identified the element at stack number one so that is the uh you can say initialization condition is that just declaration of the key maintenance will be how long we have gone and haven't achieved the key and final termination will be we have achieved the key or not achieved at all so these are the three conditions that is being dependent on or can say can be said as loop invariance in the property of searching of the element is continuing with the loop. And there is no chance that the element will be present on the portion where we have already traverses. So that is the maintenance part. Now come on to the next notation that is called as the big O notation that is written as big OH notation. So, the theta notation was asymptotically bound a function from above and below and that is why we have referred it as sandwich. Because there were line here and in between there was f of n. So now, if you see here for a given function g n, that is known function, we denote big O of g of n, here it is written big O of g of n or sometime O of g of n, then we can say that this condition should hold. So, how you can correlate with theta notation? In theta notation, what we have did? We have taken two constants, c1, g of n less than fn less than c2 g of n greater than 0, where c1 and c2 are positive constant for some n0. So, now this was theta notation. So, what we have said fn is equal to theta of g of n and the graph graph was this this was fn this was c2 g of n and this is c c1 g of n now when i say big o notation when i say big o notation so what primarily i am confirming about the worst case or what I mean to know about how much more time or what could be the maximum time the algorithm will require for its execution. Now, so if you see this expression that is c1 g of n less than f of n less than or equal to c2 g of n. So, what we can find? This is the lower bound and this portion is the upper bound. And in case of big O notation, we are primarily confining to the upper bound. So, in this case to say that a function fn is equal to big O of g of n, we have to establish f n should be less than or equal to c of g of n because here there is no c 1 and c 2, there is only one c. So, we are considering its function value as c. So, if we can establish this, then we can easily say that f of n is equal to big O of g of n. So, this means that this is a half portion of what we have discussed are done in the previous example related with the theta notation. So let us see one more thing, there is one more book if some of you are aware of that is SOM series, what it say about this big O notation. So it say suppose fn and gn are the functions defined on the positive integer, because n is what n is an input size. So, of course, it is a positive integer with the property that f n is bounded by some multiplier of g of n. So, that multiplier is nothing but c that for almost all n that is important. So almost all n means that n0, beyond n0. So that is suppose there exists a positive constant n0, a positive number c such that n greater than n0 we have fn less than c of g of n or that could be this one. Now, if we have this expression that is 8n cube minus 576n square plus 832n minus 28, so what we can conclude that we will first have to estimate C or g of n that is less than, that is greater than f of n. So, this you have to establish and ultimately we will get a computational complexity of order of n cube, that is big O of n cube. So, now we will solve some problem on it, do not worry. So, before proceeding further, just giving you the glimpse of some of the algorithms computational complexity, that is linear search we have order of n, insertion just we have completed that has a order of n square then binary search is order of log n bubble sort order of n square merge sort and log n okay so these are some complexity one by one we will explore so uh so till now we have explored linear search and insertion sort and we have identified the computational complexity of those problem. And this is how, if you remember, in G of n, in theta of n, there was theta of g of n, there was a below line. But here we are only considering the above line. This indicates that at any time this could be the maximum value of C of g n or this f n could go maximum to this otherwise it will be lower than this. So here c of g of n is above. So we have also considered the only above line expression if you remember. So same problems are there. So we will solve one. We will solve one or two problem because it is primarily clear to you because you people have already done the theta notation where we have estimated both c1 and c2. Here we have to only estimate c2. Let us consider one problem. Even we can take this bigger one but here getting n0 will be a little bit challenging. Let us try. 8n cube minus 576n square 8n cube minus 576n square plus 832n minus 28 equal to 0. Now we are estimating or we have to establish this big O of g of n. So here we are assuming g n as n cube because the high order term in this polynomial is n cube. And so what we have to do? We have to do like 8n cube minus 576n square plus 832n minus 28 should be less than c of n cube. So what we will get? c should be greater than or equal to 8 minus 576 by n plus 832 by n square minus 28 by n cube. So, c should be greater than when limit n tends to infinity, we will get what? We will get only 8. So, c should be greater than 8. Let us say we are taking c equal to 9. Then this expression or even we can take c equal to 65 by 8 or something or even 8. Then this property will hold that is f n is less than or equal to c of g of n. Now, we have to comment on when n naught when this expression becomes positive. So, we have to identify when this function is positive. So, you can take simple help of multiple hit and trials or simple ways and not you can consider let us say 20, 30, sometime you consider 1, 2. So, in the meanwhile you can determine it. But as we have discussed for a polynomial of higher, of order d, degree d, the highest degree term having the positive constant, then obviously the computational complexity of that expression will be order of that thing. So, why I was saying it is easy for you to understand when your theta notation is covered, because after that we have drawn a conclusion that if an expression if an expression is having higher order term with positive coefficient then its computational complexity will be same okay so if you estimate n naught then also you can calculate uh just taking a short break for two minutes then i will come back and take the queries okay okay rithika so provide access one by one and then i will try it so just enable their mic okay good morning sir hello yes yes you are audible please okay yeah sir uh the basic question is that while we are having the theta notation we just uh put one of the conditions that limit and stands to zero f of n and g by g of n should be equal to one yeah yeah so will that condition be forwarded to same big notation as well yes yes hundred percent later on we will also discuss if something is theta so it will be obviously we go okay so that's the question basically because as we are discussing so we can take any values like greater than uh for uh g of n yeah yeah greater than f of n so if that was the condition so basically we can't take more higher values right if yes yes yes okay so thank you so we try to identify c that is very much uh it means that least value of the c so that that that is up to you but you can also take the bigger because we are targeting from a set of values okay so if you take different c then it will you will get a different value with from same set kind of and also that that was not the question basically if f of n has higher degree polynomial of order three so if we take g of n uh or to be of order four then will that be right thing or not so that we will discuss in little o and little omega what could be the condition if f n by g n is not comparable okay so but that will not be the asymptotically uh tied bounds so that we will discuss just after completing this big o we will complete big omega then little and little omega so in that we will discuss on that what could be the situation when we are taking a mismatched f n g n to identify the computational complexity so basically sir uh the condition will hold in all the three cases right f of n by g of n should be equal to one if when n is very very large it should be equivalent okay f by fn by gn should be one okay yeah thank you sir good morning sir my question is about a loop invariance when you told that for linear search right and you only told that there is a condition that the whatever we are searching variable that is not there into the array then how the first or second or third condition will hold there okay so now in linear array first we are declaring a key okay and we are not searching the your array your location okay because the loop is not started so we are not comparing okay so now at that stage we hadn't identified the array that is the initialization in the next step let's say i have reached to the fifth index or sixth index so we are certain that before that the elements is not there before sixth index if we are at sixth index and we hadn't obtained the element so element is not beforehand okay and as you proceed further there is a chance that you will get it or not get it so invariance will come here in the sense that initialization the element was not found and as we proceed we are ensuring that the element will never appear in the left half it will appear in the right half at the leave move and at the last either we have identified the element or does not identify it at all so in this way the three conditions are holding so primary thing is that if you remember we were saying that the algorithm should be correct for the sub part or sub problem so in that way we can say that the algorithm is correct because if we have searched for five element so the element or the key value should not be present in that five element after about any time okay i guess you get the picture yeah yes sir consecutive doubt came uh let's say if this is a best sorted i mean best linear such that whatever we are searching the element that is at the first location or the second location yeah then then that is the algorithm will terminate at second iteration so that is the termination part we have identified the element at second index or first index then this maintenance and termination will not applicable to that will be this maintenance and termination let's say we have identified value at first index so this maintenance and termination will be same okay because your loop was concluded in one one iteration yeah okay thank you shubhi you are next go ahead yes i have a general question yesterday you told about assignment and mid-sim exam so i had a doubt related to that so um when i will be our mid-sim exam and how it will be will it be a google form okay so you may have received the schedule so on that i cannot comment but uh uh the the the type of questions primarily will be again objective type okay so just do the first assignment okay uh that is probably starting in some days then you will find what type of question i will ask so that will be primarily from the slides okay and from our discussion only no not beyond that okay so don't worry about that things and when the mid same will happen you will get the notification for the same dates are already disclosed so you need not to worry about all those stuff okay okay and requesting everyone uh so let's say keep your doubt is resolved uh while i am addressing the doubt of other so don't raise hand because we are there is number of people so actually i want the class will be interactive that's why i'm doing taking your doubts otherwise if i start taking doubt from all of you then it will be very difficult for me to operate okay so rithika i guess there is no more doubt we can continue uh one more sir uh we'll take yes sir good morning sir in cheetah notation like we had had said that we were ensuring two guard rails or two upper and lower bounds even within which the function should you know sustain in this case we can see that there is only an upper bound there is no lower bound so how are we ensuring that you know that end not always stays makes the function positive and it doesn't go into negative how is that guard kept and then what is the relevance of the upper bound because there is no lower bound certain by a c is required then can be valid for any value above the fn so that any value is c so you can i i will take nine you can take 8.5 someone take 20 so that is c because we are targeting that fn is not a single value fn is obtaining from set of possible values of this one one thing second thing is that here theta notation is primarily confined to identify what maximum time your algorithm could take okay what maximum execution time your algorithm could take so that's why we need not to bother about the lower one what minimum time your algorithm will take uh people will rarely ask but they are more keen to know okay what maximum time your algorithm will take so that is being catted by this big o notation thank you sir yeah uh i guess we are good to go one oh no yes good to go yes sir thank you thank you yeah now uh this was uh big o notation okay and uh as we have also discussed that for uh quadratic expression there is a predefined uh estimations, that is here also, if you had a quadratic expression a n square plus b n plus c, then we can say that the computational complexity is b go of n square as we are Concluding it is theta of n square. And here for estimating c and n naught we can use this formula c equal to a plus mod of b and n naught is here max of 1 minus b by a. So, either it will 1 or minus b by a. So, these are the two values that we can directly use when you has an algebraic expression of form or fn is of form an square plus bn plus c. Important part is that using big O notation, using big O notation, we can offer often describe the running time of an algorithm merely by inspecting the algorithm overall structure. For example, the double nested loop of the insertion sort algorithm immediately held a computational complexity of order of n square upper bound on the worst case running time. So, other things are written. You can just read for my PPT. So, worst case running time discussion is happened. So, that is why we say that theta notation for average, big O for worst and there is last one. If you remember in theta notation there were two things. This was Fn and half portion we have covered in big O and this half will be covered in big omega. So that is also easy to go. So next notation or the last notation in the asymptotic case that is called as the big big omega, big omega notation. So, here if you see this is just the half remaining half of the theta notation, remaining half of the theta notation. So, it will identify, it will identify the minimum time your algorithm will require to execute. Minimum time your algorithm is required to execute. And we go was maximum time your algorithm will require an average case theta is what? In between maximum time and minimum time. So, same the graph will look like this one because some for some c of g of n, we are assuring that f n will be always greater than this. So, this is called as the big omega notation. Now I can conclude something. If f n equal to theta of g of n, then we can conclude f n is big O of g of n and f n is omega of g of n. Why? This will use c to g of n is if you remember the condition and this is c1 g of n. So, or we can in other way we can say that if fn is equal to theta of g of n and fn is equal to omega of g of n, then we can conclude fn equal to theta of g of n. So, this is important. So, in both ways it true. If we can establish both big O and big omega notation, then we can get theta notation, or if something is theta, then obviously it will be big O and big omega. So, for that, there is a definition as well. So, this, this is given in the Corman. If f n is, sorry. So, before going further, let us check the definition of omega of g of n, omega of notation. okay. If f n is equal to omega of g of n, if and only if there exists a positive number n naught and a positive number c such that f n is greater than or equal to c of g of n for all n greater than n0, okay. So, if you remember we have solved this problem. So, f n should be greater than 18n. So, for that case, we can say that f n is equal to omega of n or for any example where we can establish a constant c such that it holds the condition that c g of n less than or equal to f of n. So, in this situation, we can conclude, we can say that the omega notation is following. So, with all this discussion, what we have done from the theta, what we have done in omega, what we have done in big O, what we can conclude that the degree of the polynomial or the highest degree of the polynomial that we are considering in Fn with a positive constant play a pivotal role in determining either theta, in determining either big O in determining either big omega because ultimately the complexity will be shifted toward that notation when n is very very large. And we know that in case of asymptotic analysis we are primarily confined about the highest or the large and large value of n or we can say that when n is very very large as it is tending towards infinity then all these things are holding. Second conclusion, what we can say that if something is theta, then obviously it will be big omega and big O. So, in theta notation, we are imposing both the bound, upper and lower, concluding the complexities lying inside this. In big O, we are bothering about, we are talking about the upper bound and in big omega we are talking about the lower bound. So I hope these three asymptotic notations are clear. Later on we will also discuss on what could be the chance if we are taking a higher GN or a lower GN. That we will discuss in little. But important part is that that will not become an asymptotic analysis. Because in asymptotic analysis, there is a restrict thing that n is very, very large and Fn by Gn should be equal to 1 when n is tending to infinity or very, very large. If this Fn by Gn is violating, then we can go for little u and little omega, but that will not be an asymptotically tighter power. So, this is important conclusion, these are the important conclusion we have drawn. So let me summarize those, then we will proceed further. The asymptotic analysis assumes this condition 1, this is important. So, it is applicable for positive function on integer of input value positive function that is the function of integer on input value and the notations that is theta, big O and big omega are also called as asymptotic bound. And also we have already done, if something is theta, then it will be big omega or vice versa. Now, I hope there is one question is striking. Sir, you are concluding that these are big theta omega and other things are in somewhere interchangeable or deducible. So, why we are studying three separate notation? So, the reason behind this is we have, let us say, the computational complexity of insertion sort is order of n square. So, this order of n square will impose how much complexity will also depends upon the situation. That is, we are doing very least less comparison. So, that is the best case. We are doing some in between comparison that is the average and worst case. So, same asymptotic bound that is order of n square will behave differently depending upon the input behavior or depending upon the characteristics of the input data. So, for that to represent all those characteristics, we have to identify best average and worst cases. So, the computational complexity, one of the good conclusion we can say computational complexity depends also upon the characteristics of the input data, characteristics of the input data that is important. So, the computational complexity depend upon the characteristics of the input data okay so if you remember i had tell one story there is a story named text and we have to identify three later word the so it is very easy but we have to identify the three later word you so it will be difficult so what we can say that the computational complexity order will remain same in most of the cases, but how much time your algorithm will take will depend upon the characteristics of the input size that whether we are getting the element on the first position or second position, we are getting the element on the last or we are getting in the middle. So, that forms the three cases that is best, worst and average case time complexities. Now, this is the theorem. This is again from third chapter of the Coorman. So, its indexing is 3.1. For any two function f n and g n, if we have f n equal to theta of g, we have f n equal to theta of g of n, if n only if if f n equal to big O of g of n and f n equal to omega of g of n. So, now I guess everyone in my class can easily reduce this, okay, just by using the definitions and just drawing this conclusion, okay. Now, till this we have assumed f n phi g n are equivalent. Now, as some of you has a jou. If we go beyond this and take a Gn that is greater than Fn or take a Gn that is less than Fn. So, what will be the situation? So, here first notation is little o. So, we have to draw a small in size. So, that is little o h. So, the asymptotic upper bound provided by the big O notation may or may not be asymptotically tight. So here in little o and little omega, we will bother about the tight bound, tighter bound. If you remember, in monotonicity, I was discussing that when we remove equality, then the bound become tighter or strict bound. And it says that he at no point of time, this Fn and Gn will be equal. Okay. So, if you talk about that. So, similarly, in case of little, this will be the situation. At no point of time, Fn and Gn should be comparable. Okay. At no point of time, this Fn and Gn should be comparable. Okay. So what could be the situation? So I have assumed a Gn that is very large. Okay. Or if you see here, you can identify the clear distinction between big O and little O. There is no equality sign. There is a equality sign. And in this case, when g n is very large or g n is just large. So, let us say as there was a question f n is 8 n cube plus 6 and g n I have taken 4 and n n to the power 4. So, what will happen when limit n tends to infinity, then 8n cube plus 6 by n to the 4 will become what? Will become 1 by infinity and that, sorry, 1 by, sorry, it becomes 1 by infinity and that becomes 0. So, this means that here Fn and Gn are not comparable and at for a larger value of n, we are getting what? We are getting Fn by Gn as 0 and that is not applicable condition in asymptotic notation. So, that if we assume a higher order Gn, just a common conclusion, if you assume higher order g n then okay then we can say that f n by g n is tending to infinity let's say um i have a function f n as 723 n square plus 32 n plus 76 equal to zero okay now g n i have taken n cube okay so may be possible for smaller values for smaller values of n this will hold but for larger value it will never hold because we know that the computational complexity will be dominated by the higher degree term okay so thus we can say that f n is equal to little o of g of n because we have consider this one and this is a strict bound but not a asymptotic bound because in asymptotic bound we are more keen how our algorithm will perform when n tends towards the infinity. So here is a problem we are considering fn equal to 2n and gn equal to n square, we can claim what fn is equal to little o of g of n. But for n tends to infinity, we will get 2 by n equal to 0. Now, there could be a reverse situation that we are having fn greater than gn. So, that if you remember that we were doing in the omega notation. So, for that there is a little omega. and for big O, there is a little O that we are discussing now. So, what little omega says, if we have considered a function g n that is lesser than f n. If we are considering a function, so in little O, what we are considering? We are considering g of n greater than f of n. In little omega, we will consider g n less, much less than f of n. If we consider this, then we are in the two strict bounds, but that is not an asymptotic bound. So, there is a definition if you see here, when f n is larger than g of n, then we will get what? We will get infinity when n tending to infinity. So, I hope you people now get an overview that what these notations are saying. So, this is little omega, this is also referred as. So, here this is the important condition. Same thing is holding as like as omega notation, but there is no equality sign. So, that is a stricter bound. So, at no point of time, we will get fn equal to g of n, any value where fn and gn are comparable. So here is an example where we have considered fn equal to n square and assuming gn is n. So we can conclude that it is fn is equal to little omega of g of n. So those who have doubt regarding if you have considered a lower value or a higher value of g of n, so I hope the doubt is now clear. so uh conclusive examples are there but before that i can take the queries okay any queries okay uh yes yes yes sir if you uh you were talking about that uh little o where you say title has to be maintained if you couldn't go to that slide where you were removing that equality sign yes if you remove equality will it be not less tight because if you go in the if it if the equality is removed i think there is uh there will be a less tightness okay equality it will just become equal so it cannot be tighter than being equal so that i mean i am understanding yeah yeah so or in different way if you think that if it is and it is very much sure now that this FN and GN should not be comparable at any instance. So that strictness we are imposing. In that sense, I was saying. Okay. At no point of time, I will make sure that this FN and GN should never be a comparable thing. So that is the thing. All right. Thanks. So assuming, yeah, a number of questions are coming. Yes. Hrithika, enable one by one. P. Raja, go ahead. Okay, next, Meenakshi. you can go ahead yes sir good morning sir uh sir in real world algorithm implementation how this would be decided that which omega or which asymptotic notation yeah that was a great question so yeah so what you can say key these notations are just for sake of nomenclature and this little o and little omega will very rare that it will be appearing okay but for completion I have to complete so these three big o big omega and big theta will appear and I am always saying we should not considerate about what notation we are using we should be considerate about the order of see that is order of n square order of n log n order of log n so if we can determine these things so notations will be if people is saying what maximum time your insertion sort will take do you know that its order is n square so we will simply put a symbol that is big o of n square if people is saying keep what could be the least time your insertion sort will take in mathematical expression so we write big omega of n square what is the average case so we write theta of n square so this means that this is just a naming convention or a nomenclature but the central idea is to determine the order of complexity n square n cube n four that is there clear yeah so that means sir we are writing the algorithms and at the back like back end there is these notations which are uh calculated and then when we say on the space and time complexities it will be can i relate this to the other subject we are also studying on this computer organization so this is actually flowing to how much time and complexity and the resources it is consuming right i mean based on this algorithms yeah narayan bibuti you're next go ahead please hello sir good morning my question is related sir we are discussing about uh growth of function that it should be the positive or input size should the positive and yeah yeah c c should be the uh you know multiplier should be the positive i'm little bit uh you like to clarify that what is the possibility that if it is negative or is there any way that because if it is zero or negative maybe the complexity or the growth is not there that's why we are not considering or not thinking about so one by one i will answer your question first thing is that uh is it possible for you to provide a negative input to algorithm so here n is not the number here n is the number of input we are supplying to an algorithm so obviously that will be a positive integer we can never make it fractional we can never make it negative so that is one thing second thing is that uh when we are saying about c1 and c2 So, if you remember, I have said that this asymptotic analysis is assuming that the computational complexity of your algorithm increases with the increase in the input size, okay, or that is monotonically increasing behavior we are trying to identify. So, we can never reach to a situation that we are increasing the size of the input and your computational complexity is decreasing or we are facing a monotonically decreasing function, okay. maybe you can design algorithm but that will not be a real-world algorithm okay so in real-world algorithm if we increase the input size your computational complexity will definitely increase that is the reason because if we start counting ten number if we start counting hundred number if we start counting thousand number so the time taken in all three cases will be different or will be increasing so so that is the more conclusive way you can say about these notations thank you sir raja shivaganish you're next uh hi sir am i audible uh yes yes sir uh i have one question like we have you told like there are three major asymptotic notations which we are focusing one is uh theta notation big o and big omega i think these are we can consider as theta if you know theta that means we are already learned the other two also right yes yes because two bounds are already covered in that yeah that is the one and second thing sir is there any possibility like you said like f of n and g of n if they are not in the same order so is there any possibility like will that happen at any point of time like my doubt like generally it has to focus like f of n is of order of n square then g of n might might be in n square only right it can that be something like n cube or something sort of i'm just so that that already we have covered in little and little omega but the important thing is that this asymptotic analysis is not a you can say uh um coming from the code side it is coming from the theoretical analysis of your algorithm okay theoretically we are analyzing an algorithm and if we have chosen a wrong choice or if you have chosen a wrong notation, so we will never conclude or determine the computational complexity. That is the one important aspect. And second thing is that if you theoretically claim that the function having n square term as g of n, so you can say it is little o of n cube, but it will not best represent your algorithm in the in the real-time execution what asymptotic analysis is doing it is just bridging the theoretical gap and the execution gap or giving you the opportunity to identify the computational complexity even before the execution of the code so that that is the difference yeah okay thank you sir thanks for your attention thank you i'm sure please go ahead hi sir my question is is the assignment going to be a proctored one or it's just uh that is again a challenging question so i'm not in a position to give an answer but primarily they are proctored they are proctored okay yeah got it okay thank you so as rithika has informed me in the starting of the class though i was late uh you people have other classes as well uh so those who have done can leave the class and i will take some of the queries if some some of you have otherwise we'll close the session uh shanthani you're next yeah hi sir uh thanks for explaining these uh asymptotic notations uh so i have one question that uh as per the asymptotic notations uh we can uh think about like that for the theta notations we always choose this theta notations for the average cases yes and uh and we go and be going up for best case and worst cases like that so we can apply these things for every uh algorithm like that bubble sort march sort and uh other other sorts and such things like insertion sort but where where we we apply the little omega and little theta sorry little omega and little o and little o notations means if we can apply this for a bubble sort it will not work right means what kind of algorithm we need to put there for calculating that complexity yeah yeah yeah so the thing is we are theoretically identifying ki our algorithm is equivalent to some known function. Okay, it is n square, n cube, n log n but this little o and little omega is just a notation that is reflecting ki what else thing could be happen if you are not choosing a correct resemblance of your algorithm. Okay, so this little omega and little o are just for a representational purpose. In real world situation it will never appear ki let's say I am saying the bubbles are computational complexities order of n cube so obviously it is not there. So this is what because you people are more curious to know what could be the thing happen when g n is large or when f n is large that is why I have told you about that notations. Or let us say we are having an algorithm and we cannot draw a conclusion from it because bubble sort is known, merge sort is known, insertion sort is known. But let us say we have make an algorithm from where we cannot judge what could be the computational complexity. so in that case we can say that but obviously it will not be logically correct because fn and jn should be comparable that means for the real uh application this will never appear that is hypothetical thanks thanks for explaining sir anu jay next good morning sir thank you so much for uh session actually um so i'm just trying to understand a basic analogy with respect to the students uh i also see there are a few students from ec background where which are not from the computer sciences in the past so for us like checking out the symbolized analysis like the the way you are giving it's kind of giving very very helpful part itself but on the other side of the picture how we can do some basic implementation i mean is there is any referential uh you can say portal or a tool which we can just start off and look forward for some basic implementation of these three asymptotic analysis uh whereas i have that book which you just referred from a city which is the road by you the best thought of if there is any other portion also which we can cover so that will help everyone yeah so uh one thing is that on hacker rank you people are getting the assignment in hacker rank let's say i search for insertion sort so you will find number of algorithms pre-existing okay so you can see those and and and and try to estimate it similarly lead code is there okay so because you all people are working professional so i never assumed you will get an extra time to learn all those things so that's why i'm very much concise about the class and lab but still if you want so lead code hacker rank code forces number of websites are there where you will go and you will find question from very basic label to very enhanced level so what wherever you are comfortable you can check it out okay and these notations uh will be let's say i write a code that's imposes the computational complexity of n square so what could be the mechanism that it could be reduced so that optimization can do yeah yeah so maybe possible your optimization will never succeed because algorithm will behave as as it is but maybe possible in dynamic programming we will see the some computational complexity drop to order of an event yeah yeah so in that way you can proceed so but but i had to consider that assume that all of people are from diverse background so i am keeping the things very uh so you can say simpler okay rather than going in a very deep dive yeah just one conservative question occurred now so when we look forward with this subject that is we have on the advanced ml side right now where we see we are also having multiple you can say ml algorithm as well as we assume that that will be going to have many complexity levels while they are actually being written so has been any kind of situation where this little omega and little o being occurred in front of you those in those algorithms all these algorithms these ml and other steps are primarily designed on basis of certain algorithms so let's say we are calling some function of lstm from some function of convolution some function of something so they are basically algorithm on the back side so if you see so they are primarily covering a complexity of n to the power four n to the power n cube log something so they are of that order okay so you can say they are more complicated to run like as insertion and other things but in the back side they are algorithm as well so if you do the asymptotic analysis so they will also behave like what we have discussed so if if we have some time so uh we'll discuss about some of the uh simplest algorithm in ml and try to identify its computational complexity in terms of asymptotic notation that would be really helpful and great of yourself so in that sense uh if you have any ever or any kind of situation this uh in in the ml side that little o or little omega has been appeared in that analysis or it's never so little o and little omega are the uh are the situation where we have wrongly chosen the fn and gn that are not comparable because we don't know about the computational complexity then we have chosen but in re if you go for real implementation and if you determine it then obviously it will be converted to big omega big big theta and other thing okay so these are the complications that if we are not aware of the computational complexity then we can easily write key assuming it is n cube but it was n square so at that time we are targeting that it is little and little omega okay so but in during implementation you will only get those three irrespective of ml algorithm you are doing nlp algorithm you are doing a normal algorithm you are doing sure and thank you so much for the guides like the way we have this book which has written for you with respect to this design and is there is any uh simpler way of understanding the ml algorithms also in a in a similar type of annotations but you can check it out because actually the thing happened about let's say author is given a task of um writing some books so they primarily refer some a textbook and and from there again the same complexity propagated there so that is the problem but algorithm is why very much close to me because i am taking the courses from last two three years so i've just written what i am teaching in the class so that is yeah in the similar direction if you can refer any book which can help on the ml site also sure thank you sir sir regarding this question only i will uh like uh add satya narana is asking like is there any way to obtain the book that you wrote regarding the algorithm so that is freely available over that portal you need not to borrow uh you need not to buy even so you can just download it if you want you can do a print of it okay yeah city has not yet released the printed version so the that is the ebooks okay so after some time it will be released then you can purchase there are some still some bugs we are revising and the fresh variant will go for a publication okay thank you sir please go ahead yeah thank you sir um if two algorithm have the same bgo complexity so in that case what other factors shall we consider to decide like which algorithm is better uh in practice that is good question so let's say two algorithms are behaving likewise merge sort and quicksort when we will discuss its cyber computational complexity of n of log n and of log n okay but merge sort uses an extra space during its execution and quicksort does not use so we refer use quicksort and its name is quick because of this property it is not using external space for the preserving the result so then we will bother about the space complexity then we will bother about the other factor that we have ignored key order of n square and n and other terms that we have ignored in the algorithm then that things will come into the picture to estimate or determine the computational complexity of your algorithm okay thank you sir one more question um is there a systematic method for analyzing the time complexity of the recursive algorithm rather than you know trying to calculate it by intuition yeah no no in recursive algorithm we will discuss about master theorem recursion tree method so there you will directly get because if you see these algorithm will never give you the uh complexity of order log of n or n log n that we are primarily discussing n square n cube n4 so for that there a separate section so it will take another two two lectures to complete so we will cover those things okay okay thank you so much sir yeah okay so i guess we are good to close uh thank you rithika for your help and first time in last two three semesters some girl has shown this courage to uh being a moderator so congratulations for that yeah thank you thank you sir yes thank you so we are closing other query we will see in the lamp