As we know that integer type variable covers 4 bytes of memory. So let's suppose we have an integer type of array with size three and also a LinkedList with three nodes.int array[3] will cover 12 bytes of memory and integer type of LinkedList with three nodes will cover 24 bytes of memory because data part of each node will cover 4 bytes and pointer part also covers 4 bytes. So each node will cover 8 bytes of memory. Collectively three nodes will cover 24 bytes of memory while integer type of array with the same size will cover 12 bytes of memory. Now, why we should use LinkedList over an array?
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (2)
sometime you cant acquire a large enough consecutive space
Do you mean that array requires a contiguous block of memory that's why we use linkedlist??