In: Computer Science
You would like to implement a list where you put in operations at any position to the list occur frequently. Would you use an array-based list? Explain why or why not?
Yes it would be good to implement a list where you put in the operations at any position to the list occuring frequently. For example in Java programming platform it contains two general-purpose List implementations. ArrayList, which is generally the better-performing implementation, and LinkedList which offers better performance under certain circumstances.
Both Arrays and Linked List can be used to store linear data of similar types, but they both have some advantages and disadvantages over each other.
We would use Array based list because of the factors stated below :-
1. An array is the data structure that contains a collection of similar type data elements whereas the Linked list is considered as a non-primitive data structure contains a collection of unordered linked elements known as nodes.
2.Accessing an element in an array is fast, while Linked list takes linear time, so it is quite a bit slower.
3.Elements are stored consecutively in arrays whereas it is stored randomly in Linked lists.
4.The requirement of memory is less due to actual data being stored within the index in the array. As against, there is a need for more memory in Linked Lists due to storage of additional next and previous referencing elements.