Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 6
Arrays are faster than linked lists because they allow for quick random access. For example, lets say we have an array: [3, 9, 4] and the linked list: top -> 3 -> 9 -> 4 -> null Now lets say we want to access the 2nd element (9). array[1]; // this gets the 2nd element directly // the value is 9 However, in the linked list you would need to start from the top and work your way to the correct element. Start at 3. That's not the second element, move to the next. 9 is the 2nd element. So, list.get(1) gives 9. But, it required an extra step. A Stack is a data-structure that can use arrays or linked lists. So, I'm not sure what to say about arrays being faster than a Stack (since a Stack can just use an array). Hopefully that answered your question xD.
19th Jan 2018, 10:06 PM
Rrestoring faith
Rrestoring faith - avatar