c# - Benefit and disadvantage of linked list or array implementation of list -
this question has answer here:
- when use linked list on array/array list? 12 answers
what advantages linked-list implementation of list has on array-based implementation of array , vice-verse?
for starters know linked-list uses more space array because has use 4 bytes of space hold reference next node , array doesn't have that. array uses less space.
advantage linked-list has on array implementation array has fixed size @ initialization , have write code increase size of array may disadvantage when compared linked-list implementation.
any ideas on else advantage-disadvantage?
for array, can access element if have index (constant time complexity o(1) ). list, have iterate 1 one access although have index (time complexity o(n))
for list, inserting , deleting element take constant time (o(1)). array, inserting , deleting take o(n) time.
for sorting, list implementation better array implementation.
Comments
Post a Comment