What are the advantages a Linked-List implementation of a List has over an Array-based implementation of an array and vice-verse?
For starters I know that linked-list uses up more space than an array because it has to use the extra 4 bytes of space to hold a reference to the next node and an array doesn't have to do that. So array uses less space.
Advantage linked-list has over an array implementation is that array has a fixed size at initialization and you have to write code to increase the size of the array so that may be a disadvantage when compared to linked-list implementation.
Any ideas on anything else for advantage-disadvantage?
For an array, you can access any element if you have the index (constant time complexity O(1) ). But for a list, you have to iterate one by one to access although you have the index (time complexity O(n))
For a list, inserting and deleting an element take constant time (O(1)). But for array, inserting and deleting take O(n) time.
For sorting, the list implementation is better than the array implementation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With