We have been seeing arrays for a while.
Arrays = Continuous memory location + same size + same data type
Why am I stressing the above points over and over?
There is a reason behind it.
See we store data in order to access them later
This essentially means accessing is the foremost important factor while building data structures
“There is no use of data without accessing it easily”
The way we place the data determines the way we access the data
Let's say we have 20 volumes of sherlock holmes.
If we want to access it easily, almost everyone’s instinct would be to place it side by step where each position resembles volumes
Like first position = first volume,second position = second volume etc
If you know the position, you get the volume
The same happens with the Array we’ve discussed
But one thing to note is that we need to know how many positions we want before creating it
Then operating system allocates space.
This prior announcement make this array a ‘STATIC ARRAY’
Let us make it dynamic.
Before that let me explain to you the need for memory and storage through MS-Word
What we do in MS-word is actually a real-world application of memory and storage
We type words before saving any document
While we type → screen actually display the words we typed before even though we didn’t save the document
How? Because it is stored in RAM memory and once we save it goes to the storage
I think you grasp the need for dynamic arrays but let me put it in words
We type a document in MS-word, prior to writing we do not know how many words we are going to type and hence memory allocation is difficult
Therefore we can’t structure it static
This leads us to the concept of ‘Dynamic Array’
Dynamic = No need to specify no of words in advance
I will explain the ‘Dynamic arrays’ concept through illustrations in the next article
Happy learning.