 Hello friends, I am Sanjay Bhukta. I welcome you on Sanjay Bhukta Tech School. So in this video, I am going to explain you the algorithms related to what the area is. So first will be how to traverse a particular area. Second is how to insert an element on a particular location of a particular area. And third is how to delete an element from a particular location from the area. So all these algorithms I am going to implement so that further those algorithms can be implemented by any programming language. So right now I am going to tell you the first algorithm that is for traverse. So this is the name of the algorithm that is traverse, then A, LB and UB. So this is the first line of the algorithm which denotes the name of the algorithm and the parameters that are required for calibration. So after this maybe you can find the brief description related to these parameters. So here A is A and B is lower bound of A and UB is, so whenever you are going to write any algorithm and after space time the parameters those are required, you can write the brief description of related to all the parameters. So that the implementer of the algorithm can understand about these parameters. And accordingly while implementing a method for that algorithm, they can use wide parameters for implementing the methods. So after this I need to write step number one. So from here actual steps of algorithms are starting. So here I am writing set K colon equals to LB. So K is the variable which is initialized with a lower bound value and this K will be used for the rotating loop. So you can say it is a loop counter and this will be declared inside the method. So that's why I have not used it as a path. So the variables which are going to be used for calculation purpose and those variables are not required to be passed as a parameter from here. You can use them directly in the algorithm. Then step number two. So after initializing this K variable with lower bound, now I am going to write a repeat statement. So repeat here I am going to use for you. So I am going to repeat step number three and step number four. So I am going to repeat step number three and four while K is less than equals to upper bound. So this way lower bound is used for initialization purpose and upper bound is used for termination condition purpose. Now step number three. So in case of step number three, now we need to write the process. So let's say we have traverses. So traverses can be done for any purpose like if you want to print the elements of array, then you need to traverse. If you want to count number of elements or if you want to count even odd numbers or the critical number. So in all those cases you are going to traverse that. So here commonly I am writing a statement applied process and two A of T. So A is our array and K is the counter variable. So initially it will be pointing to the lower bound. So here A of T means first location of array. So you need to apply the process on first element then on second element then third element and so on. So after this process you can write step number four set A equals to A plus one. So K is initially having the lower bound value. After applying the process on that we can increase K by one so that A will be pointed to the next location. And here you can write end of step two then step number five that will be end of this algorithm. So this way this is a simple algorithm that is for traversing a one-year. So I hope you understood how it is working and you can easily convert this algorithm with any programming language. So you can implement it with the help of C, C++, Java or any other programming language. And accordingly you need to define the data type of array or all the variables that are used in this algorithm. And also notice that in case of algorithm lower bound will be always one and upper bound will be always equals to A. And whenever you are going to implement this algorithm in any programming language. So in most of the programming array starts with zero and lower bound will be end sorry upper bound will be end minus one. So in case of DSA always remember we are going to use these values for lower bound we are going to use one for upper bound we are going to use n. And in case of programming most of the programming not all so lower bound will be zero and upper bound will be end minus one. So accordingly you need to put the logic. So here you can see lower bound case will be same but while you will be implementing this in your programming. So you need to remove this equals to zero so that this condition will be full of it. So this was all about traverses. So after this now I am going to explain the insert. So removing these. The next is insertion. So let's say name of algorithm is insert. So here we will be using these parameters A and K and item right. So here A is array and is elements of array. So N is representing total number of elements of array then K is the position. So K is the position where we need to insert the number and is the value to be inserted right. So these are four parameters that we are going to use in this algorithm. So now I am going to write the steps. So step number one is again set similar to traverse. So here I am going to write J equals to N. So J is again loop counter. So that's why it is not mentioned here. And A is the number of elements of size of array. So J is the distance that N then step number two. So here I am going to write repeat. So repeat is again for the loop. So it will be repeating step number three and step number four while J is greater than equals to K. So this is the loop combination condition right. And I am going to take step number three and four with this. So now step number three. So here the step number three will be. So step A of J plus one. So A of J plus one will be having value of A of J. So whatever value will be in A of J that will be assigned into A of J plus one. So let's say first index value will go to second index value will go to third index. So this way it will work. Then step number four will be set. So here we are going to decrease this J variable by one. So J started from N and it will be detected until K. So this is the case then. So here you can see step number three and four which we are repeating. So here we can write N couple and then you can write step number five. So after completion of this loop, you need to write the step number five. So step number five will be set A of K equals to item. So the item will be inserted into A array at A position. And the step number six will be set N equals to N plus one. So we are going to insert one more element in the array. So that's why its size will be interpreted by one. And then step number seven will be N. So this way this is the algorithm for inserting an element. So now I'm going to take an example so that we can understand it properly. So let's say these are the six positions one, two, three, four, five, six. Name of array is K and it is having these values already available. 11, 12, 13, 14, 15. And I need to insert on fourth position item is 20. And right now we have five elements. So size of N is five. So here you can see array is defined. N is five, K is four. So on fourth position we need to insert an element. And either that needs to be inserted is 20. So now come here. So we need to set J with N. So J will be equals to N. So here I am writing. So J is five. Now come here to check this condition. J greater than equals to K. So if it is two. So right now J is greater than equals to K. So it is two. So we need to perform this. A, J plus one will be having A, G. So A, J is the fifth location. J plus one will be the sixth position. So here 15 will be copied. Now we are documenting J by one. So J will be four. Again check this condition. So it is again true because J and K both are equal. So one more time this value will be shifted because J plus one will be having J value. So J plus one will be five this time and J is four. So this 14 will be copying here. So 15 will be removed. That's what 14 will be copying. But 14 is still here. It will not be used. It will be erased and we will be putting any other value over here. So again J will be implemented because of this. Then check this condition. This time it is false because J is not greater than equals to K. So it will be terminated. Now A of K equals to item. So what is K? Four. So A of four position will be having item that is complete. So this way you can see we have inserted value successfully and will be implemented by one. So its new value will be six. So this way this is the algorithm to insert an element on a particular position of the M. So I hope you understood this as well. So now third one is remaining that is what we need. So now I am going to write third that is for delete. So here you can see all four parameters that we use then insertion are available. A adding and is the total size. Case of position from where we are going to delete that item will be storing the deleted element. Right. So here A is added and is size of added. Case is the position to be deleted and item will store deleted element. Right. So whatever value will be deleted will be stored in item. So now I am going to write step number one. So step number one will be set item equals to A of K. So key positions value will be assigned to item. Then step number two will be repeat steps. Right. So we are going to repeat step number D and four while J equals to K. So J will be starting from A position and it will be between two minus one position. Now we need to write the step number three. So step number three will be set A of J equals to A of J plus one. So A of J plus one value will be assigned to A of J. So in insertion we shifted the element to write inside in deletion. We are going to shift the element and step number four will be set J equals to J plus one. So it will be invented. Then here we can say end of loop. So loop will be committed. Then step number five. So here we can write step N equals to N minus one. And step number six will be N. Why N minus one? Because we are deleting one element. So it's total size will be indicated by one. So this way this element is committed. Now I am going to explain this. So let's say we have this position fourth that we inserted. So K will be four and is six. So starting from here item will be A of K. So item will be having the value as 20 because A of K is 20. Then J will be starting from K. So J will be four and it will go to N minus one. So that will be fifth position. Now A of J plus one will be assigned to A of J. So A of J is four. So J plus one will be five. So fifth position value will be assigned to fourth position. So here 14 will be shifted. Then J will be invented. So this time J is five. Check this condition. J should be less than equals to N minus one. So N is six. So six minus one five. So five five both are equal. So it means this will work one over nine. So J plus one is 15. And J will be having this value. So 15 will be shifted to here. So J is having five. So six position value will be shifted to fifth position. Right. And again if we increase the value of J because of this. So this time you can see this condition is false. Because here N minus one is written. So it will be calculated. Total size of N will be implemented. So it is five. So only five elements will be processed. So six is removed from here. So wherever you will be implementing this algorithm. It's the help of any programming. So you need to consider the value. You need to reduce the size. So here you can say maybe you will be using dynamic traffic. So that dynamically you can increase the size of the area or increase the size of it. So I hope this way you understood how we can traverse the area. How we can insert the element at a particular position. And how we can delete an element that is available on a particular location. So all three algorithms are related to data structure to one area. And if you want to watch their implementation with C. So in the description you will find the links for playlist related to both. And at the end of this video you will also find new steps. So I hope you understood how we can implement all these three algorithms. So thank you for watching this video.