Tripadvisor Interview Question

Other than an array, what data structure has O(1) insertion and O(1) search?

Interview Answers

Anonymous

Oct 14, 2011

The array does not have O(1) search.... It takes O(n) if it's unsorted, O(log n) if sorted, but if it is sorted, then insertion is no longer O(1)

2

Anonymous

Oct 7, 2011

A hash table

1