I am studying the concepts of array and linked list ,
Which is speed in terms of accessing and why ?
Can anyone clarify this ?
Thanks in Advance .
I am studying the concepts of array and linked list ,
Which is speed in terms of accessing and why ?
Can anyone clarify this ?
Thanks in Advance .
The array is faster than the linked list.
Finding the nth element of an array is O(1); just start at the beginning and perform one operation in pointer arithmetic. Finding the millionth element takes exactly as long as finding the tenth.
In a linked list it's O(n): you must start at the beginning and step from node to node until you reach the one you want. So finding the millionth element takes 100,000 times longer than finding the tenth.