Sunday, March 29, 2015

Difference between array and linked list with Point



Difference between array and linked list with Point




Aspect
Array
Linked List
Size
·        Fixed Number
·        Size need to be specific during declaration.
·        Grow and shrink since of insertions and deletions.
·        Maximum size depends on help.
Storage Capacity
Static  It’s location is allocated during compile time.
Dynamic : It’s node allocated during run time.
Order and Sorting
Stored Consecutively
Stored randomly
Resizing
Resizing is never necessary
Resizing is necessary
Access Mechanism
Random access is efficient
Random access is inefficient
Accessing the Element
·        Direct or Random access method.
·        Specify the array index or subscript
·        Sequential access method
·        Traverse starting from the first node in the list by pointer.
Searching
Binary search and Linear search
Linear search
Memory Usage
Wastes memory in unused positions
Uses only the memory needed for the data actually in the list.
Insert in Middle
Insert in middle requires shifting
Insert in middle is efficient after locating previous.
Insert in beginning
Add to beginning is costly.
Add to beginning is fast.
Insert in end
Add to end is fast
Add to end is costly if it is singly linked list.






0 comments:

Post a Comment