Difference between Array and Linked List
-> Both Linked List and Array are used to store linear data of similar type, but an array consumes contiguous memory locations allocated at compile time, i.e. at the time of declaration of array, while for a linked list, memory is assigned as and when data is added to it, which means at runtime.
-> In this Article we explain full details about difference between Array and Linked List-
Array in C / Data structure-> Both Linked List and Array are used to store linear data of similar type, but an array consumes contiguous memory locations allocated at compile time, i.e. at the time of declaration of array, while for a linked list, memory is assigned as and when data is added to it, which means at runtime.
-> In this Article we explain full details about difference between Array and Linked List-
BASIS FOR COMPARISON | ARRAY | LINKED LIST |
---|---|---|
Basic | It is a consistent set of a fixed number of data items. | It is an ordered set comprising a variable number of data items. |
Size | Specified during declaration. | No need to specify; grow and shrink during execution. |
Storage Allocation | Element location is allocated during compile time. | Element position is assigned during run time. |
Order of the elements | Stored consecutively | Stored randomly |
Accessing the element | Direct or randomly accessed, i.e., Specify the array index or subscript. | Sequentially accessed, i.e., Traverse starting from the first node in the list by the pointer. |
Insertion and deletion of element | Slow relatively as shifting is required. | Easier, fast and efficient. |
Searching | Binary search and linear search | linear search |
Memory required | less | More |
Memory Utilization | Ineffective | Efficient |
Definition of Array
-> An array is defined as a set of a definite number of homogeneous elements or data items. It means an array can contain one type of data only, either all integers, all floating-point numbers, or all characters. Declaration of an array is as follows:
int a [10];
For more Deatils about Arrays visit the post:-