I have a problem which uses many insertions in the list at the beginning and afterwards search and retrieval operations are extensively used, So which approach is good and efficient?
Approach 1: Use LinkedList
as my data structure for the whole program.
Approach 2: Use ArrayList
as my data structure for the whole program.
Approach 3: Use LinkedList
as my data structure at the beginning for insertion and do
Arraylist al = new Arraylist(ll);
for retrieval operations.
How much does the changing of data structure cost?? Is it actually worth doing it?
ArrayList
? It relies onSystem.arraycopy
, which is a native method, so I suppose it should be faster and optimized?