I have a question about fundamentals in data structures.
I understand that array's access time is faster than a linked list. O(1)- array
vs O(N) -linked list
But a linked list beats an array in removing an element since there is no shifting needing O(N)- array
vs O(1) -linked list
So my understanding is that if the majority of operations on the data is delete then using a linked list is preferable.
But if the use case is:
- delete elements but not too frequently
- access ALL elements
Is there a clear winner? In a general case I understand that the downside of using the list is that I access each node which could be on a separate page while an array has better locality.
But is this a theoretical or an actual concern that I should have?
And is the mixed-type i.e. create a linked list from an array (using extra fields) good idea?
Also does my question depend on the language? I assume that shifting elements in array has the same cost in all languages (at least asymptotically)