So, yesterday we started discussion on the summary of the asymptotic notation and we identified or summarized that there are three main notations that is big omega and big theta and there are two other notations that is little on and little omega. So, they are used when the ratio of Fn and Gn is not equivalent or we can say that when we have chosen a value that is not equivalent to the value that is specifying the property of an algorithm. Then we have seen some example as well, then in the summary part, we were discussing on how this theta big O and big omega are represented for different functions. So what we identified that for any type of function, when we are targeting to identify big O, big omega or big theta, so we have to always identify the highest degree term in the problem with a positive coefficient, then we can directly claim that without being calculating c1 c2 c and not we can directly say that the computational complexity of this algorithm is order of n cube or n square likewise here if you see in this case we are saying that it is order of n cube here we are saying it is order of n square here we are saying it is order of n square so these are the some examples then for little omega and little we have identified that when fn is less than gn then we have to confine to the little o and when fn is greater than gn when fn is greater than gn then we are concluding or saying it is little omega when fn is less than gn then we are saying it is little o so these two things you have to remember you have to identify the function fn and gn and accordingly you have to decide. Then we talk about different properties of the asymptotic notation. One was reflexive. This means that the function is asymptotically bounded by itself. Reflexivity means a function is asymptotically bounded by itself. So like fn equal to theta of fn, fn equal to big O of fn and fn equal to big omega of fn. So this property is called a function is bounded by a function is asymptotically bounded by itself. So function is asymptotically bounded by itself. This property is called as the reflexivity. Second property was transitivity. So, here it is a function is bounded by another function which itself bounded by third function. So, we are saying if a function is bounded by another function, okay. So, let us say I am doing f2, this is f1 and this is f3. Then we can say that then f1 is bounded by f3, okay. So, this was transistivity. Then we have seen symmetry that if fn equal to theta of gn, then we can say that gn equal to theta of fn. So, this means that because we know that this fn and gn are equivalent when n is very large in that case we can simply establish this that fn is equal to theta of g of n similarly gn equal to theta of f of n so we have seen some then then we have discussed about the additive and multiplicative properties so additives say that when multiple operations are happening in your algorithm okay, but they are sequential, not sequential and independent, okay. When multiple operations are happening in your algorithm, which are sequential and independent, then we can, while estimating the computational complexity, we simply add their contribution by identifying the maximum time consumed by your function or we can say that the dominating operation in the algorithm or dominating looping operation or anything in the algorithm. So, that will be the computational complexity of the algorithm. Likewise, if we have some big algorithm, this part is imposing n log n and this part is imposing n square. So, in that case, in max of n square and n log n, obviously, it will be n square. So, that is the additive term. Then multiplicative term is if there is a dependent things happening. So, if I write for additive property, if multiple independent operations are happening in a, you can say algorithm, then dominating portion or you can say function will responsible for computational complexity. If there is a dependency, then it will be multiplied. If there is a dependency, then there is multiplied, that is multiplicative property. Then we see some questions and this solution. In summary, we have identified that the asymptotic notation provides us a capability to identify the computational complexity of two algorithm or help in identifying the algorithmic selection. Then next thing is, it provides a simplification and abstraction. It provides of simplification and abstraction then of course it is platform independent irrespective of where we are learning algorithm from this analysis we can determine how much time the algorithm will take and we can predict the scalability as well as how if we increase the input size so what is the behavior of the algorithm okay then after this we have started discussing about the divide and conquer approach. So divide and conquer says that if the problem size is very large, so without being directly solving the problem, what I will do, we will divide the problem into sub problem, sub sub problem, so that it can reaches to a very small size. And afterwards, we will do a conquer operation where we will try to solve the sub problems or sub sub problems and then ultimately we will combine. So, in divide and conquer approach, there are three stages. Just give me a minute. The first one is divide, next one is conquer and next one is combine. So, three stages divide, conquer, combine. So, divide means this large problem is partition into small, small, small, small, small and so on. and conquer means that use divide and conquer algorithm to solve the sub problem associated with the subset. Then there is combine, take the solution of the sub problem and do a merger. Then we started discussion on the one of the famous divide and conquer approaches or the problem that is called as the merge sort where our target is to divide the problem till we have reached to a situation of single element label. So division strategy is divided in such a manner that we have reached to single element label. Then what we will do? We will start doing the conquer. We will start doing the conquer or combine. So recursively sort, then we will do a combination operation. So in case of merge sort, what we are doing for our given array A, what we have to do? We have to recursively divide, we have recursively divide the array into one element composition. Then what we will do then? we will merge two elements and sort the subset. Third, repeat until we have reached to our solution. So what basically we are doing, we are dividing a problem into to sub problem. And this division will continue until we have reached to a situation where we are at 11 element label, then we will start conquering or combining. So then we discuss on stable predictable performance. I am not going into it. So let us take this example. I will solve, then we will see the visualisation of it in this page, it is 85, 24, 63. The array is 85, 24, 63, 45, 70, 31. So yesterday also I have told, so this array is not always an even number, it is allowed to have odd number as well. division strategy, you have to choose 45, 70, 31, 96, 50. So we have this array 85, 24, 63, 45. So I am just giving how this algorithm will work. So 85, 24, 63, 45, 17, 31, 96 and 50. We have this array. Let's count if you count 1, 2, 3, 4, 5, 6, 7 and 8 element. So n by 2 will be what? 4. So division point will be this one. So in one part you will get 85, 24, 63 and 45. 5. In another part, you will get 17, 31, 96 and 50. Okay. Then we will first try to solve the left portion. Okay. And then we will solve the right. So, again here the elements are 1, 2, 3, 4. So, what we will get? 2 subpart 85, 24 and here we will get 63, 45. Okay. Now, we have to solve first the left one here 1, 2. So, we will get 85 and 24. So, first this portion will be solved then we will switch to these portions. Okay. Now, let us choose some more color. So, now we have 85, 24. So, what will happen basically? So, we are on the, so we will first solve leftmost. Okay. Now, so I will take the queries. Now, here 85 is S1 and 24 is S2. now we are shifting toward the result so what will happen s1 is compared with s2 from first element so what we will found in capital s we will store 24 and then 85 so this is the resultant part and here the resultant is 24 85 that will be stored then this half portion is done. Now the control will shift toward this one. This will be divided into 63, 45 and again this is S1, this is S2. So in S what we are storing? S we are storing 45, 63 and here we will get 45, 63. Okay. Now if we have to solve this then we have 2 sub array S1 is 24, 85 and S2 is 45, 63. So starting with this first element, so which one is smaller? So in S, 24 will go, then 45 will go, then 63 will go and then 85 will go. So this is simple comparison. So resultant of this step in the reverse order will be 24, 45, 63 and 85. Now we will start division over here that is 17, 31, 96, 50 then division goes 17, 31 and then we will solve this. So, what will be the value S1 17, S2 31 resultant will be 17 and 31 itself, then it will be divided 96, 50. So again, yes, 50 will come, then 96 will come and here we will get 50, 96. Then we have S1 as 17, 31 and S2 as 50, So, in S what we will get? We will get 17, 31, 50, 96. So, resultant of this step will be 17, 31, 50, 96. Now, we have to get the last result. So, here S1 we have 24, 45, 63, and in S2 we have 17, 31, 50, 96. So, ultimately what we will obtain S equal to 24, 17 which is small 17, 31, 24 which is small 24, 31, 45, 31, 45, 50, 45, then 50, 63, 50, then 63 96 63 85 and 96 so this is the resultant so this is how we can solve this problem okay and we'll take we'll take queries just a minute so just give me a minute so those who are raising query enable their mic okay right now there is no one and yes yes no plus i am yeah yeah so my question is let's see the biggest term has a negative coefficient so in this case you ignore it or will not take as a so that is not solvable by the asymptotic analysis so that is the assumption the highest order term should be have a positive coefficient then only this asymptotic analysis can be applied okay thank you sir thank you subhashish hi audible yes yes please so yeah so the last part which you have explained about merge sort was not properly visible to us i think the screen might have frozen so if you can explain the last portion after you divide it yeah division is clear yes yes the revision part is clear after that the merge so here this was the merger thing so i will continue with this yeah the merger portion yeah yeah sure one more problem the pattern your mind is allowed so there is no more anything okay okay sure let us continue so uh later on uh when i i have already shared this ppt you can check it out how the steps are running but the important operation in the merge sort is the merge operation okay so that i will explicitly demonstrate and that is in the ppt as well okay so this is called merging of the two sequences, how we can merge two sequences, that is important. So if you see when there was one element, then also I was writing s1, s2, then combinedly form s. So similarly, when we have two sequences and that are already sorted, because we know that as the algorithm proceed, the sub array are sorted. And let us say we have two subsequences that are already sorted. So how this merge algorithm actually works. Let me finish this, then again I will come for the queries. Now we have two subsequences. So if you see this was from first part and this is from last part. Two parts were the first and last. And now how this actually algorithm works. So it will compare first element with first element. Whichever is smaller will be pushed into the final array s or you can say resultant array s. Now, then first element since it is not moved of s1 will be compared with second element of s2. So, what we identified it is smaller. So, 24 will come here and will be eliminated from here. Then now the point, so if you see here, this pointer is i, it was starting from 1, now it become 2 and here initially it was i1, now it become 2. The second element, sorry this is j, the second element that is j is compared with i. So what we found that 31 is smallest. So 31 comes here, then what will happen, then this will compare with this. This will compare with this. Then what is the mechanism? 45 will be smaller. So that will come. So here there are two pointers. One is j and one is i and they are moving toward the end point by comparing one by one element label. So that is the strategy. Now 45 will come. Then 50, 63 will compare. Then what we will get? 50. Then we are getting 63. Then we are getting 85. then we are getting 96. So in this manner, we can do the merger or merge of two sub sequences. Now, if we have the problem that is 1, 2, 3, 4, 5, 6, 7. Now we have 1, 2, 3, 4, 5, 6, 7 element. okay and if you do 7 by 2 int what you will get 3 so here if you can see here 3 element and then 4 element okay you can also use int ceiling flow that is totally up to you then what will happen here it is 3 so 1 and 2 then we have 1 1 1 element level then then we will do a merger. So, here there is only one element and here will be two elements. So, they will be further propagated and divided. Then afterwards what we will get? We will get 27, 38 and 43 as the resultant of this portion. The resultant will be what? 27, 38 and 43. So, what I will do? I will again solve this problem without jumping into that annotation part. So, that was an issue. So, I will solve this problem and then I guess the things will be more clear to you. And this algorithm again we will understand how it is working. Just write down the problem 38, 27, 43, 38, 27, 43, 3, 9, 82, 10, 10. So, this is our problem. now the sample size is seven element okay we have only seven element division rule simple n by 2 so what we will get two server is 38 27 43 then 3 9 82 and 10. one portion is this one and another one is this one. Then we will again divide then what we will get 38 in one part and 27 and 43 in another part. So, since there is one element so there will be no further movement then this will be divided at 27 and 43. So, again s1 is 27 and s2 is 43. So, resultant s we will compare this so we will find 27 and 43. So resultant of this one will be 27 and 43. Now we have two sub array one s1 is having 38 and s2 is having 27 and 43. One to one element comparison so in s first element will be 27 then 38 and then 43. So this will be the resultant of this sub half. Now we will shift to this portion where we will get this 39, 82, 10. Now 39 will be 3, 9. Then S1, 3, S2, 9. Combining we will get 3, 9, the same resultant. And here we will get 80 to 10. Then S1 is 82. S2 is 10. So, resultant S will be 10 and 82. So, that will go ahead that is 10 and 82. Okay. Now, we have S1 with 3 element that is 27, 38 and 43. Then S2 we have 3, 9, 10 and 82. 3, 9, 10, 82 and here we have 27, 38 and 43. Now first element will be compared with first in S what we will get? 3, then 9, then 10, then 20, 7, 38, 43 and 82. So this will be the resultant of the this problem, where the elements are odd, but we can proceed and we will discuss on this part. So, how this part is actually working? So, if we will take queries, just which if length of array is less than 1, then we have to return the array because nothing merging or anything you have to perform. Otherwise, what we will do middle equal to length of array by 2. So length of array was what? 7. So we have done. So the length of array was 3. Then what in left half what we will get? ARR till middle. And this is a python script. What we will get from 0 to 2 in left and from 3 to 7 in right. So that was 4 element and this was 3 element if you remember. Then again on the half portion this merge sort is calling. Then what it is doing, so 3 element then is further, it is not equivalent to 1, so it will be further divided into left and right portion that was 38, 27 and 43. These were the 3 elements, so 38 will, we will get 38 and we will also get 27 and 43. So that is happening on the left portion. So what we are seeing that left, left, left, left will executed first, then we will shift to the right. And when the division is over, then we start calling what? It is return merge. So, for example, 27 index is going and 43 index is going, that is S1, S2. Then they will reach us to the merge operation, that is critical part of the merge. Division is easy to go. Division is easy to go, but this one is, important and critical part. So let us say if you remember this problem, so index of 27 was 1 and 43 was 2. Here assuming a python script with an index is starting with 0. So we have exempted the index of 38 that was 0. So a of 1 was how much? 27 and a of 2 was 32 elements we are considering for the addition. Now we have declared one empty list of result. And what we have put left index, left index, right index equal to 0, we will see later on. So while left index less than length of left, length of left is 1, right index less than length of right that is also 1. So these two conditions fulfill. Then what we have to do if left of left index less than right of right index. So what we are getting? Left of left index that is 0 is less than right of right index. Then what we have to do? Result was the empty list append left of left. So we are just comparing this. Then we will increase the left by 1. Otherwise what we will do? We will append the right by 1 or here it is extend the right by 1 and ultimately we will get the result. So basically what we are doing, here we have initialized left index and right index as 0. So we are comparing left of left index and right of right index and here so left is a subarray. So if you have confusion, so this is subarray and this is also a subarray. Here it is written a left half and right half. So, these are the basically the arrays. So, we are picking first element from this, first element from this and comparing if left portion 0th index is less than right portion 0th index, then what we will do? We will append or in the result list that is empty, we are adding one element and increasing the left by one. So, first element was compared with this. if we found it is smaller then in the resultant we are adding this element and our cursor is moving ahead otherwise what will happen result will be appended by the this first entry right will be incremented by one and result extend the left left index okay and then we will move further so this is basically the same phenomenon that was happening here So this portion is important. If we have initialized with zeroth index, we have picked this left and right are the, this left and right are not the indexes, they are the sub-arrays. That is important. So either this will happen or this will happen. So let me take the queries, then we will talk about the recurrence relation for this one. your mic is allowed because your mic is allowed hello sir good morning good morning let's be louder yeah yeah can you hear me yes yes i can hear sir can you explain how we are calculating the middle uh thing i mean uh we we know that middle equal to length of parent but in case of if we have let's say odd number seven by two is how much into value okay and will yes three yeah those that we are using so here this length by two or middle if you declare middle as a int variable then you will get a definitely a three okay okay so we are just considering the end value yeah yeah yeah so you are free to use floor ceiling int but it should be common be once you declare it should be specific it should be same throughout the problem okay okay thanks so i think your mic is allowed sir good morning what is the result extend is doing so in case of append we are adding one one element okay so result dot if you talk about after doing this to comparison we have appended either from left index or right index then we are extending or we are you you can say you are incrementing that I have to check but after append I don't think okay fine extend is the operation of adding extra spaces here if needed okay result dot extend so the result was having one element via append now it could extend it for further more entries so this is specific to the Python only okay okay yeah so just check it out so basically what will happen if I append so one element is appearing then we are getting the room for other element because this is a dynamic nature now we have added one element then for adding more we have to extend it got it so just check it out these two okay yeah your mic is a good morning sir good morning so can you please explain the procedure of merge with an example that how we are doing the merge yeah yeah in accordance with the procedure yes with respect to this how the algorithm is working yes yes yes yeah yeah that that is good okay so this extend the last question was just adding the extra entries in the just adding extra entries or extra empty spaces in the list, because initially its size is 0, then we have added one element, then furthermore, we have to do this or we will come to it. This is an important question he is asking. So what actually happened? Why extent is using key? Let us say we do not, we have when is all the entries in one sub array. So, we will directly add it. This extent is doing what? Let me do, show me one, give you an example. Let us say s1, I will revoke that what we can say. Entire steps just after this. So, let us say in s1, we have 0 entry and s2, we still have some 74, 75, 73 and the s array is having 1 7 9 already sorted then in that case when there is no element remaining in s2 so we will directly cut down this and add here so either it could be right sub array or left sub array so if you see here it is saying result dot extend left index still last that is when there is no element in the right and this will happen when there will be no element in the left okay so what i am trying to convey if we are doing the comparison sort of thing and at any point in any sub array there is no element so the next sub array will be automatically appended without comparing okay so i hope so can you enable mic for the last who was asking for extent it is clear now it is fine it is clear now why exchange is using yes if one sub array is having element but other is having 0 element in that case will be automatically cut down and extended in the server in the final result okay okay if it could be left portion or it could be right portion because that will be already sorted and then that is already sorted so that is extending okay so at that time when you ask to i just forgot to mention okay so that is important part and in that case the comparison will be lesser. So, let me take this, make one slide. This is the procedure. So, now assuming one example where left is a sub array having these element that is 17, 19, 23 and 45. Another sub array that is right is having four element. I am considering four cases, you can consider anything. Okay, that is totally up to you. it is having 16, 20, it is having 16, 24, 49 and 95. These are the two sub array. So, now our left is this one and right is this one. I have declared an empty result. Result is a list that is initially empty now we have these are the indexes if you say 0 1 2 3 these are the index what I am doing left index equal to right index equal to 0 that I have declared now what I am doing while left index is what 0 is less than length of left so length of left is how much 4 and that is and operation right index that is 0 less than length of right that is 4 so what we have to do if left that is array 0th index because initially this left index is 0 is less than right 0th index so what we found no this is fail this fail then what we will do we will go to the else part. So else says result dot append. What I will append? Right, right index. So right, right index is 0. So right, 0th index will be appended into the result. So here I am making the result part. Here let us put result. Is what now? It is having one entry that is right 0, that is 16. And after completing this, what I am doing? So, result dot extend. Now, result index, right index is incremented by 1, that is from 0, it is now reaches to 1. So, this is over. Now, we are at this index in right and this index in left. Then what we will do we will again do a uh this while loop operation and what it say if left index okay if left index uh just coming in a while in in the meanwhile you people can think just taking short break then i will come to the queries as well okay so uh let us continue so there was one more hand yes yes sir good morning sir sir uh algo of merge shot is understood my only simple doubt is after seeing this algo and the way it works here we are taking a very simple example from academic point of view of six seven items yeah yeah had it been you know uh one million ten million items and the memory it is very high and as you have seen the properties and drawbacks that it requires additional space to store all this that means twice amount of space is required to sort this array so is this the most efficient from industry and the you know uh standards or do we have something better than this so better than this is the quick sort quick sort that is quickest algorithm so that we will see i guess in the next class so that will not use extra space so it will utilize same array for sorting so that's why its name is quick sort all right thank you yeah So, now we have added one result 16 here. Then you can see left index is still 0 and right index is now 1. And here it is, I guess there is some indentation error that we will check out later on. So, let us focus on this. Now we have added one entry into the result. 0 is compared with length of 4 and 0 is compared with, so here it is saying right index, that value is now 1 is less than length of right, is less than length of right and now length of right is how much? 1, 2, 3. So, length of right is 3, so while 0 less than 4 and 1 less than 3, that is because right index has been incremented by 1 and the length of array is now reduced to 3 because one element has already been exempted. In that case, if you check if left index that is 0 is less than this. So, at this time if condition will fulfill and result will be appended by one value that is result dot append that will be left of 0. So, now in result one more value is coming that is 70 okay then what will happen now left is left index is one and array length is three so in next while loop what we will do while one is less than three and one is less than three so 24 19 will be compared then 19 will come then two is less than two operation will come okay Because length of error is now 2 and while index has been shifted to 2. So, in that case, if you see there will be fail in the condition, then we will come out of it and we can extend. So, either we can extend left or we can extend right depending upon the values that are left. So, just a recommendation or suggestion to all, just follow this step or in the next class what I will do on pen and paper, I will solve a problem following all the steps and that I will add to the PPT. Because here in the constraint space, if I am solving and I am in a doubt that there is some indentation or some error is here, that may hamper. So better to take up this problem in the next class where I will solve entire problem, taking an example, putting all the steps as someone was asking for and then I will solve this. Because if there is some bug here, so entire problem will be disturbed. So better to go in the next class and see the result or what I can do while uploading the PPT, I will also upload a full-fledged example for this one, following all the steps. So by evening, I will add it and share with you. If you still have any doubt, then I will happy to help you out in the next class. So let us move further. So here, this is called as the recurrence relation, how your algorithm is behaving. If we are dividing n into 2 sub problem of n by 2, and we are taking order of n for combining. So this is the recurrence relation representing the merge sort. So there is a discussion that in division of area of n takes order of one time because we are not comparing anything we are just calculating n by 2 n by 2 n by 2 and then dividing the conquer part the recursive call to the sub problem occur until sub list contain one element will take log of n and merge operation will take order of n because we have to compare n by 2 element with n by 2 so maximum comparison could be n so that's why this is the recurrence relation if we have problem of 4 it will divide into 2 2 and there Here combine will take n. So, this is log of n. So, this is called as the recurrence relation representing the this and the discussion so for asymptotic analysis that we have considered there we were directly estimating the computational complexity of the algorithm. But here to solve the recurrence relation we have some specialized method like master's method or recursion tree method or guessing the solution method. So that we will see later on after covering the divide and conquer. So just this representation, if you see if you have problem of 8, you will get 2 problem of 4, 4 and while combining the requirement time is order of n. So this is simply reflecting how your algorithm is behaving. And for the problem being, I will solve this and add in this slide and then share. So then it will be clear and in the meanwhile I will also check the issue in the indent. Now let us move to the next problem in this segment that is called as the binary search. I hope you people had, some people had idea. So what is the basic idea in binary search? If you had a sorted array, you had a binary search just discussing the basic idea. You had a sorted array. Sorted means that in ascending order probably. And you have to identify a key value. So we had a sorted array. Let us take 1, 7, 9, 24, 29, 9, 31, 35, 45, 1, 2, 3, 4, 5, 6, 7 and 8 elements are there, even you can do 9th element. Now I have to identify the key 45. So what I will do since this array is sorted, so I will, we add this index, then same formula n by 2 I will apply. So, I will reach where? 4 here and here what we found at fourth index the value is 24. The value is 24. Then we will compare with the key that is 45. So, what we found? 45 is greater than this one. So, this portion is irrelevant for us. So, we will start searching in this portion. Then we have how much element? 1, 2, 3, 4, 5. So, 5 by 2. So, we will take second entry. Now, we will reach to this situation and this portion is done. Now, 31 will be compared with 45. Then this portion is done. We have to check out here. So, now then we have 1, 2, 3 and 3. So, we will get 35. So, 35 is compared with 45. So, what we will found this portion is irrelevant. So, we will come to 45 and 51. now 45 is compared with 45 and then when then we declare the reserve so basically what we have doing we have problem of n then we are moving only in n by 2 eliminating this one then n by 4 eliminating this one so basically what is happening if if you compare with the recurrence relation t n equal to t n by 2 and we are just doing one comparison with the middle element with the middle element and therefore if you someone knows the computational complexity of binary search is log of n because array is already sorted. So, this is an interesting problem of divide and conquer where half portion of the array is remain inefficient or it is unusable when we know actual direction of the moment. So, let us consider one problem that is is having values 6, 13, 14, 25, 33, 43, 51, 53, 64, 72, 84, 93, 95, 96, and 97. So here low index is 0 and high index is 14. So do not confuse, you can start indexing with 1 or 0, that is totally up to you. Now, we have to identify a key that is 33. So, here 0 to 14 indexes are there. So, first time we will reach to the seventh. So, again, if you take n by 2 ceiling, then you will reach to 7. Otherwise, you can take n by 2 floor or you can take n by 2 int. That is totally up to you. Here we are taking the ceiling value of n by 2. So we have reached to seventh index. Now we will compare 33 with 53. So what we found that it will never lie in this direction because array is already sorted. So we will now consider this portion only for our search. Then 0, 6. So we will reach to the next time. We will reach to the index number 25 because that is a middle element. Now we will compare 33 with this. So this portion is in efficient, and we remain with this. Okay, then we will consider then we will get 43, then we will then 43 then this portion is irrelevant. Then last we are having 33 and that is as well as the low as the high index, and then we are getting the resultant. So in this portion, at each step, we are removing or we are reducing the search space. Each step reduces the search space and that is the beauty of this algorithm. And therefore, the computational complexity reaches to log of n. So here if you want to search 20 in this. So what I will do? 1, 2, 3, 4, 5, 6, 7. I am considering let us say n by 2 ceiling. So we will reach to 100. Comparing 100 with 20, what we will get? The value may be lying in the left, not in the right. Now we have this portion on which we have to work. Now this is 1, 2, 3, middle element will be 2, 20 is compared with 20. We declare the result, we have find the 20 in just two comparison, one was with 100 and another was with 20. So this is the good thing about this algorithm. So, how this algorithm work? If k key is equal to a n by 2, then we are done. If k is less than n by 2, search k between a 0 to n by 2 minus 1. If k is greater than n by 2, then search k between a n by 2 plus 1 and a n minus 1. So, repeat until either k is found or no element exists to search. So, this is the simple concept of this algorithm. And if you go with this simple example, this is I guess C implementation. So, here what we are doing, if a mid is k, then print found. Otherwise, if k is less than a mid, then we will put what? High mid minus 1, else mid equal to high plus low by 2. So, this is the simple you can say representation of binary search. In next class, we will see one more example on binary search. I hope you get the idea. Basic idea is identify middle, compare with key and determine the direction whether I should go left or right. If the middle element is greater than key, so search left. If middle element is less than key, then search right. this is the simple phenomena that we can adopt while doing the binary search okay so if anyone has any doubt let me know or we'll close the session because the next algorithm that we will see it is a quick sort and we will start in the next lecture i am seeing some queries are coming yes yes sir raja you think is allowed uh hi sir uh this is ganesh and uh i have one doubt sir uh regarding the previous class uh what we have discussed uh i think um you told about much sort is in place and also uh there is some other thing called as a stable sort much thought is not in place sorting not in place means that the result will be stored into another array yes yeah yeah stable like like if you see this uh our insertion sort is an in place right sir yes it is in place and the stable sort both are stable source like yes yes both are stable means that the order of the element in the resultant array will remain same yeah one more question sir regarding this much sort for example if we have the duplicate elements over there sir then how like do we need to include is equal to while comparing sir how it goes sir in the much short okay okay so yes yes yes i i i got your idea so when you are saying that there is two 20 20 is coming so how you will proceed while merging okay so when we are saying uh 20 is less than 20 so of course you can say no so so that concept you can apply okay but the problem that i have considered it was a distinct element not duplicate element if there is a duplicate then your algorithm will go as it is and you will get the result you can check it out with an example 20 less than 20 fails so obviously what will happen then that that we will see okay sir thank you sir thanks sir because your mic is allowed sir can you explain the recurrence property it's not clear to me if you could adjust okay this is the recurrence relation okay how it is coming if we have a problem of size n then what we are doing we are breaking the problem into 2 n by 2 and taking order of n time in comparison agree yes yeah so if if your problem is problem function is tn so we are basically doing what tn by 2 and taking order of n so this is the recurrence representation so why why this multiplied 2 i mean why they're because because we are dealing with two sub problems now if n then there is n by 2n n by 2 so 1 n by 2 1 n by 2 that is 2n by 2 okay okay makes sense and in case of binary such just continue right so tn will be equal to how much t n by 2 because we are removing half percent and just doing one comparison order of one so this is recurrence relation for buying research okay so one more question around the trade-off that we have so let's say if we have a huge data sets millions or billions of data elements In that case we have to have the trade-off between space and time complexity. So what is that trade-off, I mean how we can decide that whether we should go ahead with the time complexity or the space complexity. So actually what happened when let's say we are doing with millions or 10 millions of the element and we does not have sufficient memory to execute or we have just very limited memory where we are executing so obviously then we will compromise with time and if we have um abandoned memory then obviously we will go with the so preference will be given to the time always okay but if there is a space constant then we will follow the second plan b otherwise we will always confined to the time complexity okay okay okay yeah okay sounds thanks hi sir uh good morning i hope am i audible yes yes please yeah so as you mentioned that for a binary search there is a tn equals to uh tn by two plus order of one and you give an example of that 20 thing so for a base time complexity you can consider that the time complexity for a binary search is order of one and rest of the cases log of n right yes yes so for actually what happened log of uh n is also um there but in best case we are doing just one comparison we are doing just one comparison so in that case uh after first division we are getting so order is all log of n but we are getting its value one that is the thing okay thank you sir yes am i audible yes yes you are already so i doubt like when we are using this short function in python directly it uses this uh team sort i was saying so can you explain that once uh please repeat your question team sorting sort it is so that that i will uh check and let you know okay so sort function directly sorts your problem but uh you can say uh um i will i will check i will check and let you know in the next one okay and romesh here yes thank you good morning sir so could assume asymptotic analysis could you please explain with example the multiplication property actually i have some additive properties clear with you yes okay good so uh have you done matrix multiplication via using c programming or any programming language yes so if you remember what was actually happening there is one for loop running for some time inside that for loop there is another for loop there is another for loop inside that there is another for loop okay so if this run for end time this will also run for end time and this will also run for end time but the thing is for this one time it is running end time and for its one time it is running end time so what is basically happening this for loop is running end time plus end time plus dot dot dot okay okay and then this for loop is running for another end time so what we will get it will multiply yes it will be multiplied then last for loop will so it will be n into n into n so it will be n q yeah okay so okay one two so on so one two three loops and for add to what i said one for look here completed another for loop is so whichever is taking more time will be dominating and edited film will take it up okay thank you sir you want your mic is allowed yes yes good morning sir good morning sir why we are doing this time complexity calculation in case of this sort but i can say uh merge sort so much not actually we can not directly assess the computational complexity that's why we have taken this is a recurrence relation later on we will see how this recurrence relation is help in identifying the computational complexity of n of log of n directly determining if it is following the property of log of n it is very much difficult okay but we know the computational complexity then we are saying here but um for this recurrence relation we will solve by master theorem that its computation complexity is n log n so it means sir whenever we have this recurrence operation so we always with color time complexity correct correct we calculate the time complexity by master method or recurrence tree method or uh simple guessing method so substitution method so that we will see later on but directly we cannot estimate the computational complexity of these functions or these algorithms okay okay sir okay thank you sir yeah i guess we are good to close that there is one more because is oh no no i have already asked the question okay thanks Hello. Yes. Yes. Yes. Good morning, sir. My question is that in the academic calendar, it's written that the date of assignment one is from 11 September to 15 September. Okay. So, but I think, sir, assignment one is not given in there, I think. So, I will check with the team i have already uploaded on 7th so maybe some of the faculty member has not yet done so that's why it is dealing but i don't know the exact reason and stage so that means you have not uploaded right the assignment i have uploaded on 7th 7th as well you have uploaded it yes yes yes but you your assignment will appear your assignment will be it will uh we you can see it is guided by the that uh administrators now so i will upload then it will reach to you after some time when the administrator let it be okay because it's not showing sir it's not showing it is common for everyone okay it is common for everyone so if your time is delayed then you will get extra time for solving it so sir in how many days it will show so i will ask with the team what they are doing so then then then you will let them answer mid semester will not go mid semester will not happened in this no yes everything will happen okay sir okay okay okay there are four hands just raised okay just summarizing if there is the the things are related with the assignment quiz and everything so assignments will be uh given to you so if there is any change in the assignment schedule then it will be reflected on by uh by us so there will be assignment there will be mid same there will be and same and there will be and there will be a lab assessment also yeah so all the things i will take in form of objective questions so do it and you have only one choice correct so i guess that is easy to go and if you have any issues or anything so i will ask with the team key what are the things then let you know at this stage i am not in a condition to ask to resolve all the queries that are originating non-technical okay if you have so i will first check with the team then i will uh then i can resolve it okay because sir end semester exam date is from 1 december from 1 december to 30th hi yes yes so let's say if there is a delay then it will be also shifted so that is not the problem okay so don't worry about assignment and other things if it is delayed you will get extra time if it is not delayed then you it will happen on same that is not a problem you will get at least two three days to solve it so just one hour you can sit anytime yes sir one point regarding moodle so many of us are not getting a mail and we have already raised the concern to uh program coordinator and they didn't revert it we are still not getting any mail any confirmation regarding the class schedule or the cancellation so in your moodle there is an announcement section if there is class cancellation if there is assignment so you can just check it out no it's not regarding assignment i'm fine with assignment daily or something but it's regarding the mail outlook mail the concerns have been raised actually same issue i am also facing i will check it out uh with them why they are not responding so there is any staff issue or anything then then they may resolve it okay yeah yeah okay thank you okay so So thank you.