Pergunta de entrevista da empresa Meta

What is a memory-efficient way to store a vector of integers? Follow-up question: using your proposed data structure, find an algorithm with constant memory usage to calculate the dot product of two vectors.

Respostas da entrevista

Sigiloso

21 de ago. de 2014

Could be simply an array (though ArrayList is also fine since it is almost the same). The operation of dot product is just as easy as it could be, with the constant extra memory equaling one integer for storing the result.

1

Sigiloso

15 de out. de 2014

Genc: I am sorry, this is not much of an answer, what you are saying is I would use ArrayList instead of Vector, you might as well say I would use a Vector DataStructure. I think the right answer is specifying the size of growth, SizeDoubling Vs Increase of 50% size, depending on type of data environment (for a generic vector definitely array doubling at 75% increase and 25% decrease)