I was asked in a .net interview the significance of linkedlist in .net. I answered that linkedlist is used where you have to do a lot of inserts, but I have never had to use linkedlist in any of the code I wrote. The interviewer then told me that all the lists in .net use linkedlist as its underlying type. When I came home, I couldn't find anything online to support his statement. Can anyone comment on the validity of his statement?
-
5The interviewer was wrong, could have been bait. – H H Jul 15 '13 at 21:06
-
5The interviewer is wrong - `List
` uses an array (`T[]`) as the underlying storage type. – D Stanley Jul 15 '13 at 21:06 -
This is a pretty good comparison as well. http://stackoverflow.com/questions/169973/when-should-i-use-a-list-vs-a-linkedlist – Dennis Rongo Jul 15 '13 at 21:11
-
This may be true in a very conceptual sense: when you're running on the metal and you need to increase or delete elements arbitrarily, a linked list would be practical. However, when you're talking about .Net, a List is not a LinkedList. – Reacher Gilt Jul 15 '13 at 21:12
3 Answers
I think your interviewer simply wrong.
LinkedList, by definiiton, is a list of entites connected with each other, so in order to get to some item X
, you need traverse all the list, all along til that item. There is no way you can access that item via index(just an example).
LinkedList
is just a different datastructure, and for sure it wasn't used on all BCL
list types.
It's very convenient choice when your going to have linked enitities and consume small memory (no additional data need other then pointer to neighbor), but you pay a cost of traversal/picking/removing/updating speed on it.

- 61,654
- 8
- 86
- 123
-
_"There is no way you can access that item via index"_ except by traversing the linked list from the first element to the next `n` times. – Cédric Bignon Jul 24 '13 at 00:40
MSDN says That the c#
List<T>
is like an ArrayList
The List class is the generic equivalent of the ArrayList class. It implements the IList generic interface using an array whose size is dynamically increased as required.
This implies that the plain List<T>
is not a linked list.

- 30,851
- 12
- 72
- 100
-
-
@HenkHolterman I don't know. Something in me just can't comprehend the idea of a Linked list being called equivalent to something called `ArrayList` – Sam I am says Reinstate Monica Jul 15 '13 at 21:10
-
Anyway, your answer only moves the problem to _"how is an ArrayList implemented"_ – H H Jul 15 '13 at 21:14