Computer science

Arrays

what is an advantage of arrays over linked lists?

Asked by
Last updated by Jill W
1 Answers
Log in to answer

"Any element in an array can be directly accessed with its index; however in the case of a linked list, all the previous elements must be traversed to reach any element. Also, better cache locality in arrays (due to contiguous memory allocation) can significantly improve performance. As a result, some operations (such as modifying a certain element) are faster in arrays, while others (such as inserting/deleting an element in the data) are faster in linked lists."

Source(s)

geeksforgeeks.org/linked-list-vs-array