Q1 When would you use a linked list instead of an array?
Show the answer Hide the answer
When you insert and remove in the middle far more often than you read by position.
An array gives you element 5,000 instantly but inserting at the front shifts everything. A linked list inserts anywhere in constant time once you are holding the node, but finding element 5,000 means walking 5,000 links. In practice arrays win more often than theory suggests, because walking contiguous memory is enormously faster than chasing pointers.
What it is really testing. Whether you know the cache answer. Almost everybody gives the textbook comparison; the candidate who mentions locality has used a profiler.