hi guys
now i will talk about the difference between common data structure (Array - Array List -LinkedList)
and when use every on ...lets go
Array
used to store data in contiguous memory locations and all data has the same type and size
use index to retrieve data this mean all data in array has the same access time
but defect in array is it has fixed size and you must defined size in initialization and can not exceed
Array List
array list like array but it has dynamic size through when you exceed initial size system will resize array with new size that allow you to insert new elements without problem even if exceed size it can duplicate its size another advantage in array list is it use object base type so you can store different data type
the disadvantages of array list it effect on performance when you exceed initial size there is overhead to allocate array again with new size
Linked List
linked list make to fix problem of fixed size in array through used pointer to next item with data
so each node in linked list will have data and pointer to next node
the advantage in linked list it has dynamic length you can store data until memory complete
But problem is there is overhead because every node contain data and pointer
and access time of every node not equal because to access the last node in linked list you must pass on all node to arrive to the last data and this may affect on system response speed
No comments:
Post a Comment