散列(插入)

时间:2017-04-27 07:57:59

标签: algorithm list hash

如果我通过将输入值重新定位到下一个空槽来使用基本的碰撞处理,那么我不需要总共n *(n + 1)/ 2次点击吗?

示例:

输入:0,0,0; ​​

分配大小= 3;

因此,总共需要6次点击才能分配所有三个值。

我读过最坏的情况复杂性是O(n)但是不应该是O(n ^ 2)呢?

2 个答案:

答案 0 :(得分:0)

平均为 $('.mgu-ekl-info').tooltipster({ functionBefore: function(instance, helper){ $.each($.tooltipster.instances(), function(i, instance){ instance.close(); }); }, contentCloning: true, timer: 2500, trigger: 'click', 'maxWidth': 280, 'minHeight': 280, animation: 'grow', interactive: true, arrow: false, distance: -10, contentAsHTML: true, theme: 'tooltipster-shadow' });

在最坏的情况下确实是O(N)

答案 1 :(得分:0)

每次插入平均为O(1)(具有良好的散列函数和调整大小策略),但在最坏的情况下为O(N)。所以在最坏的情况下N插入是O(N ^ 2)。

相关问题