Data Structures are different ways how we organize collection of data in comupter memory for faster/efficient/easier access to a perticular data in that collection. Data structure goes hand in hand with algorithm, at first we organize collection of data in a specific way, which we call a Data Structure and then we write some instructions/steps to how we can access/modify/insert/delete individual elements in that Data Structure, which we call an algorithm for that Data Structure.
The most basic data structure is a fixed size array. An array stores all of its elements next to each other, meaning if an array holds all of its data in memory range of 0-15 and it stores int type values then each element will occupy 4 bytes. So, when data is inserted it will put the first int in memory 0-3, next will be put in 4-7, next is 8-11, next is 12-15. So, basically to in an int array the data at i index will be at the memory position of i*4
and it will occupy the range i*4
-(i*4)+3
. And there are many a