0
3.4kviews
Differentiate between Array and Linked list.
1 Answer
written 5.8 years ago by |
PARAMETER | ARRAY | LINKED LIST |
---|---|---|
Define | Array is a collection of elements having same data type with common name. | Linked list is an ordered collection of elements which are connected by links/pointers. |
Memory structure | In array, elements are stored in consecutive manner in memory. | In linked list, elements can be stored at any available place as address of node is stored in previous node. |
Insertion & Deletion | Insertion & deletion takes more time in array as elements are stored in consecutive memory locations. | Insertion & deletion are fast & easy in linked list as only value of pointer is needed to change. |
Memory Allocation | In array, memory is allocated at compile time i.e. Static Memory Allocation | In linked list, memory is allocated at run time i.e. Dynamic Memory Allocation. |
Types | Array can be single dimensional, two dimension or multidimensional. | Linked list can be singly, doubly or circular linked list. |
Dependency | In array, each element is independent, no connection with previous element or with its location. | In Linked list, location or address of elements is stored in the link part of previous element/node. |