Recently I was learning about the difference between Array and Linked-Lists. There I found that:
- In Array memory is allocated in compile-time. In the case of Linked-List memory is allocated during the execution on runtime dynamically.
Then I saw a comparison video between array and linked-list made by Computerphile There I learned about some key differences in the runtime of an array and linked-list in machines having a cache memory and not having it.
Now I was wondering that,
In the case of allocating a large number of data (e.g: 10^7 integers) is there any difference between:
- I allocate 10^7 blocks in the memory at the beginning of the program (e.g:
int ar[10^7];
~ Declaring array in C) - I allocate 10^7 blocks one by one while taking input dynamically (e.g: implementing linked-list)
If there are differences indeed, how significant is that?