Question
What is the difference between arraylist and linkedlist?

Answers

Underlying data structure for ArrayList is Array whereas LinkedList is the linked list and hence have following differences -

1) ArrayList needs continuous memory locations and hence need to be moved to a bigger space if new elements are to be added to a filled array which is not required for LinkedList.

2) Removal and Insertion at specific place in ArrayList requires moving all elements and hence leads to O(n) insertions and removal whereas its constant O(1) for LinkedList.

3) Random access using index in ArrayList is faster than LinkedList which requires traversing the complete list through references.

4) Though Linear Search takes Similar Time for both, Binary Search using LinkedList requires creating new Model called Binary Search Tree which is slower but offers constant time insertion and deletion.

5) For a set of integers you want to sort using quicksort, it's probably faster to use an array; for a set of large structures you want to sort using selection sort, a linked list will be faster.   Your Comment




More Software,Java Questions..
What is the inputsplit in map reduce software?

Can variables be used in Java without initialization?

What is the difference between java bean and enterprise java bean?

What is software configuration management?

How does the java database connectivity (jdbc) work?

What are the advantages of threads in java?

What Is Java Api For Xml-based Rpc (jax-rpc)?

How can you implement fine-grained auditing?

What is IBM’s simple explanation for Big Data’s four critical features?

What is static synchronized method in JDBC API? Give an example?

What does the NULLIF function do?

What happens if a start method is not invoked and the run method is directly invoked?

Should we override finalize method

what is the difference between mysql_fetch_array and mysql_fetch_object?

How will XML affect my document links?

What is object cloning in Java?

Why to use Style Sheets?

What are Filters in MVC?

Can you explain Application layer in OSI model?

How to define new testplan attributes?



Search
Can you Answer!!
  • Q      Explain what are components in Joomla?
  • Q What is Domain Naming Service (DNS)?
  • Q Angiosperms are _____.
  • Q How do enterprise beans handle concurrent and loopback calls on entity beans?
  • Q In an economy, the sectors are classified into public and private on the basis of
  • Q Which protocol you would recommend for testing performance for .net applications implemented with ajax and why?
  • Q If you could be granted three wishes for making the world/society/ your community a better place, what would they be and why (or, If you were given a million dollars to achieve three goals, what would you work on and why)?
  • Q In what sport are ten pieces of wood separated by a chain
  • Q Mecca located in?
  • Q Why do i get bizarre errors when trying to submit data, particularly problems with groupset?
  • Q Who among the following was appointed by Ashoka to administer justice in his empire ?