Please explain what is the advantage of linked list over an array. And also is there any advantage of using array compared to linked list.
Regards, Shoaib
If you don't know the amount of objects you need to store beforehand, a list is probably what you want, since it's very easy to dynamically shrink or grow the list as needed. With this also comes the advantage of being able to easily insert elements mid-list without any need for reallocation.
The disadvantage of a list vis-à-vis an array, on the other hand, is that it's slower to select individual elements, since you need to iterate. With an array, you won't have this problem. Arrays, on the other hand, are troublesome to use if you need to resize it, as this operation is more costly than adding or subtracting elements from a linked list.
Lists should be used more commonly, since the ease of use is often more beneficial than the small performance gain from using a static size array.