30 Nov 2019

  • November 30, 2019
  • Amitraj
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-




BASIS FOR COMPARISONARRAYLINKED LIST
BasicIt is a consistent set of a fixed number of data items.It is an ordered set comprising a variable number of data items.
SizeSpecified during declaration.No need to specify; grow and shrink during execution.
Storage AllocationElement location is allocated during compile time.Element position is assigned during run time.
Order of the elementsStored consecutivelyStored randomly
Accessing the elementDirect 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 elementSlow relatively as shifting is required.Easier, fast and efficient.
SearchingBinary search and linear searchlinear search
Memory requiredlessMore
Memory UtilizationIneffectiveEfficient




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:-


                                                  Array in C / Data structure

Translate

Popular Posts