Data structure that allows accessing elements by index and delete them in O(1)

前端 未结 4 1509
眼角桃花
眼角桃花 2021-01-05 15:40

I have following task (as part of bigger task):

I need to take an k element from array like data structure and delete it (k is any possible index). Arra

4条回答
  •  天涯浪人
    2021-01-05 16:15

    I believe what you're asking for is impossible.

    However, if you can relax your requirement for indexing to O(log n), then ropes may be able to satisfy it, although I'm not sure if they have a probabilistic or deterministic guarantee (I think it's probabilistic).

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题