 Hello friends, I am Sanjay Gupta. I welcome you on Sanjay Gupta Tech School. So in this video, I am going to explain how you can calculate addresses of 1D array. So with the help of a formula, we can identify address of a particular index of 1D array. So for that, first I am going to write the formula. Then I will be explaining that formula with the help of an example. So this is the formula through which we can calculate address of a particular index of 1D array. So here we have various terms. So let's understand those terms first. So A is 1D array here, right? So one dimensional array. So wherever we have a little capital N, so it will be representing 1D array. Now K. So K is the index of element whose address we want to calculate, right? So this will be the position whose address we are going to calculate. Then P A, so it is base address of array. So base address of array means starting address of a particular array. So this is covered, this is covered, this is covered. Again here we have 8, so A is representing an array. Then we have W. So W is the word size of data type. So W is the word size of a data type or element, word size or data type of element in memory. So let's say you are using this array as a type integer. So for integer, size of a particular block or its data type size is next to the whole byte. And if we are talking about long end or we are talking about float, long, sorry, float, double, long, double. So in that case, size will be different. So as per your data type or whatever element you are storing in memory. So W will be telling you the size of that individual block. And K is already explained and Lp here means lower bound. So lower bound will be always 0 because the first index of each one of the array is 0, right? So now I am going to, after this explanation, I am going to take an example so that we can calculate the address. So let's say if you are working on 16 bit compiler. So in that case, if you are working on 32 bits compiler then in that case, size of it will be 0. So I am going to tell you both the scenarios. So let's say we have one array in which we have various elements to, right? So these are the elements which are stored in this array. Now we need to calculate the address. So we need to calculate the address of this second index. So if I create the array, so these are eight locations. These are indexes. These are the values which are stored. And let's say bringing address is 1000, right? So base address of this array is 1000. So if we are working on 16 bit compiler, right? 16 bit compiler if you are working on. So size of it will be 2 bytes. It means each block will be given 2 addresses. So first we are going to understand this. So now we need to apply this formula. So base address is 1000. So base address is okay. Just we have calculated. And plus w will be 2 because we are working on 16 bit. Now K is the index whose address we want to calculate. So it is 2 minus lower bound will be always 0. So we need to put that. Now 1000 plus. So this will be 2 into 4. So finally what will be the output? It will be 1004. So the first block and this is our 1000 and 1001. Next is 1002 and 300. And this is starting from 1004 and actually go to 1005. So here you can see at beginning address of A arrays, the main index is 1004, which is totally correct. Right? So if a particular location is having multiple addresses, because if location is having more than one bits. So according to the number of bits, that location will be having those particular addresses. So if location is of 2 bytes, it will be having 2 different addresses. So the beginning address will be identified with this. Right? So this I explained you on 16 bit. Now if I take 32 bit example. So in that case this int will be of 4 bytes. So rest of the thing will remain same. Only I need to change this. And 4002 will be 8. And the result will be 1008. So here from 1000 to 1000d, these 4 bytes will be reserved here. Then 1004567 are reserved for here. And starting from 8, 9, 10, 11. So 1008 to 10011. These 4 bytes will be reserved for this second index. So here you can see 1008 is the result, which is correct for the second index. So here you can identify this. So this way you can calculate address of a particular index for 1d arrays to this formula. So I hope you understood how this formula is working. And you can apply it on any data type. So the data type which we are using for arrays, we need to put the memory size in case of data. And rest of the things are very simple. So this way I hope you understood how we can calculate address of a particular index in case of 1d arrays. And if you want to watch more videos related to data structures or data structure we will see. So you can go to description of this video. You will find various links there. Also at the end of this video I have put those various links. So you can follow them there. So I hope you understood whatever is contained in this video. Thank you for watching this video.