Pergunta de entrevista da empresa Amazon

Consider a simple array. What is the time complexity to insert, search, delete an element?

Respostas da entrevista

Sigiloso

5 de dez. de 2011

You're both wrong it's constant time to look up an element at an index. Insert and delete are dependent on implementation, most languages require you to re-size or make a new array, so it's n/a for the most part. And search (if you mean find an element with value x) is O(n) (at worst).

3

Sigiloso

9 de mar. de 2011

Constant

Sigiloso

27 de mar. de 2011

Its O(n).. not constant!

1