I know linkedlist
is faster in insertion and deletion in java because they use linked list datastructure which is group of nodes. I tried to understand why it is faster in insertion and deletion.But I did not understand. What I have undersstood is Each node is composed of data and a reference to the next node. Now, How it is efficient because of this? can I anyone explain me in simple way? Sorry I am not a computer science student.
Just have completed Bachelor commerce.. :)
Asked
Active
Viewed 66 times
1

user414967
- 5,225
- 10
- 40
- 61
-
1faster than what, exactly? if you're comparing to arrays, the main reason is because an array has a fixed size, and so would need to be 'recreated' on insert/delete – jbutler483 Dec 04 '14 at 09:54
-
@Eran you pointed to an also duplicate answer: http://stackoverflow.com/q/26737018/3584765 instead of the original: http://stackoverflow.com/q/322715/3584765 – Eypros Dec 04 '14 at 09:58
-
@Eypros I pointed to the same question asked by the same user. – Eran Dec 04 '14 at 09:59
-
@Eran I still don't get why you should point to a question that is also duplicate and not the original one even if it's of the same person. It's like chain answer instead of the direct one. Anyway, I made my point clear won't comment any more – Eypros Dec 04 '14 at 10:34
1 Answers
0
In case of linked list, there is no boundation that it should be saved in contiguous memory, so where ever there is space in memory, JVM puts object there and points that object from last element of the list.
But in case of say, ArrayList
, if JVM does not find contiguous memory space, JVM finds new memory area that can accommodate complete ArrayList
and then copies complete list to that space, hence adds overhead.

codingenious
- 8,385
- 12
- 60
- 90