Can an item in a linked list be referenced directly like an array?



Can an item in a linked list be accessed directly like an element in an array?


NO, a linked list needs to be traversed starting at the head of the list to reference a particular item. An array structure works by allocating a block of memory to store all the contents of the array. Each element of the array has the same size - either by being a primitive data type such as an integer or floating point number or by being a fixed size reference to another piece of data like a string. Since each element of the array is a fixed size, the item can be referenced directly by computing the index into the array multiplied by the size of each element. This allows for direct access to data in the array. The items stored in a linked list are allocated as needed so they are not necessarily in a contiguous block of memory. The list must be traversed starting at the head to get to a specific element.