Search Interview Questions
| 3306 questions in repository.|
There are more than 200 unanswered questions.
Click here and help us by providing the answer.
Have a video suggestion.
Click Correct / Improve and please let us know.
|Java - Interview Questions and Answers|
|Ans. ArrayList are implemented in memory as arrays and hence allows fast retrieval through indices but are costly if new elements are to be inserted in between other elements. LinkedList allows for constant-time insertions or removals using iterators, but only sequential access of elements|
1. Retrieval - If Elements are to be retrieved sequentially only, Linked List is preferred.
2. Insertion - If new Elements are to be inserted in between other elements , Linked List is preferred.
3. Search - Binary Search and other optimized way of searching is not possible on Linked List.
4. Sorting - Initial sorting could be pain but lateral addition of elements in a sorted list is good with linked list.
5. Adding Elements - If sufficiently large elements needs to be added very frequently ,Linked List is preferable as elements don't need consecutive memory location.
Sample Code for ArrayList
Sample Code for LinkedList
|Help us improve. Please let us know the company, where you were asked this question :|
|Like Discuss Correct / Improve  java   collections   list   arraylist   linkedlist   difference between   architecture   data structure   ebay Asked in 2 Companies basic   frequent|
Try 2 Question(s) Test
|What is the difference between ArrayList and LinkedList ?|
| Is this a valid initialization ? Explain.|
Collection<Collection> collection = new LinkedList<LinkedList>();
|In a Linked list with sorted numbers, insert a new numbers while maintaining the sort order.|
|Difference between ArrayList and LinkedList ?|
|Find the third last element in a linked list ?|
|Write a program for LinkedList, with method to append node and traversing the list ?|
|Write method to delete Node from a LinkedList.|
|Difference between List and LinkedList ?|
|Is it legal to initialize List like this ?|