D
D
Dair_Targ2010-12-24 17:48:47
Algorithms
Dair_Targ, 2010-12-24 17:48:47

Data structure

Suggest a data structure for which:

  • Insertion time: guaranteed O(1) (preferably at the speed of inserting into a linked list)
  • Access time to an arbitrary element by its number in the list is also guaranteed O(1) (preferably with the speed of access to an array element)

The structure will store pointers or integers. The running time of other operations does not matter.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
M
MikhailEdoshin, 2010-12-24
@MikhailEdoshin

In my opinion, the only option with the expected O(1) is a hash table. If the data is known, you can choose the perfect hash function and then O (1) will be guaranteed.

E
Eol, 2010-12-24
@Eol

Fibonacci heaps ?

K
kefiijrw, 2010-12-25
@kefiijrw

ummm. I'm afraid to embarrass myself in front of the entire district, but ... a dynamic array?

A
Artemzr, 2010-12-25
@Artemzr

A hash table is probably the most suitable option. To eliminate collisions, replace each element with a list or do open addressing.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question