Explain the concept of static and dynamic representation of linked list with example.
Answers
Answered by
4
Static memory allocation is a compile time constant i.e. memory is allocated during compilation of the program. For example,
int main(void) { int fours[10]; /* fours is an array of 10 integers */ char symbols[128]; /* symbols an array of 128 characters */ return 0; }
When above program is compiled, fours is allocated (10 * sizeof(int)) bytes, symbols is allocated 128 bytes. Here memory is allocated during compile time. We call this static allocation because memory is allocated once at the compile time and we can’t request for reallocation if need arises. Further, we can’t free up memory once we are done with this. Memory allocated statically frees up only when program exits.
please mark it as a brainlist
int main(void) { int fours[10]; /* fours is an array of 10 integers */ char symbols[128]; /* symbols an array of 128 characters */ return 0; }
When above program is compiled, fours is allocated (10 * sizeof(int)) bytes, symbols is allocated 128 bytes. Here memory is allocated during compile time. We call this static allocation because memory is allocated once at the compile time and we can’t request for reallocation if need arises. Further, we can’t free up memory once we are done with this. Memory allocated statically frees up only when program exits.
please mark it as a brainlist
Similar questions