Pergunta de entrevista da empresa Tradeweb

Difference between Linked List/Array List. Which is better for insertion in the middle?

Respostas da entrevista

Sigiloso

21 de jul. de 2017

Array list is array backed vs head/tail nodes. This is the question where they told me to look up what the JDK does. I of course picked the LinkedList since the question explicitly said in the middle and how inserting into an array causes elements to be mass copied. They told me ArrayList actually did better though. I then proceeded to talk about how I was aware of the System.arrayCopy() that ArrayList used for insert but was personally unaware of whether or not that provided enough performance to beat the theoretical difference with a LinkedList. They didn't care/care to admit that I actually did know what I was talking about.

Sigiloso

19 de set. de 2018

From stack overflow: ArrayList: dynamically re-sizing array. Pros: iterator. Cons: Element search LinkedList: double linked list. Pros: read access. Cons: add/remove involves shifting