Linked List VS Array

1) Linked list
Definition :- Linked lists are the collection of node, which are dynamically created and nodes are li ked together by the pointer reference. 
Advantages :-
1) Linked list size is not fixed, they can expand and shrink. 
2) Insertion and Deletion operations are fast and easier with O(1) complexity. 
3) Data Structures like stacks, queues, and trees can be implemented  using linked lists. 

Disadvantages :-
1) Memory consumption is more, since every node need extra pointer in order to connect to next node. 
2) Sequential access only possible, random access can't be achieved. 
3) Reverse traversing is not possible. 

Application :-
=> Suppose, I want to develop an application, such that it should respond quickly and more memory consumption is not a problem, In this case we use Li ked Lists in our applications. 


2) Array
Definition :- Array is the collection of homogeneous data types. 

Advantage :-
1) Array can be accessed randomly using the array index. 

Disadvantages :-
1) Data elements are stored in contiguous locations in memory and causes External Fragmentation. 
2) Insertion and Deletion operations are costlier, since the memory locations are consecutive. 
3) Memory is allocated at compile time. So, Static Binding. 
4) Size of the array must be specific at the time of array declaration. 



Comments

Popular posts from this blog

Can 5G Network Kill Humans?

Virtual Reality is the Future Fantasy