动态哈希表调整大小中的立即复制与增量复制

发布于 2024-10-04 23:59:32 字数 119 浏览 0 评论 0原文

各自的优点和缺点是什么?如果我正在实现一个哈希表,其中快速查找时间至关重要,那么似乎我应该使用立即,因为这只发生在插入和删除时,而增量也会减慢查找速度。这有道理吗?

如果重要的话,我正在用 C 语言做这件事。

What are the advantages and disadvantages of each? If I'm implementing a hash table where fast lookup time is crucial, it seems like I should use immediate, because that would occur only on insertions and deletions, whereas incremental would slow down lookup as well. Does that make sense?

I'm doing this in C, if it matters.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

清旖 2024-10-11 23:59:32

除非您对每个哈希表操作都有严格的时间限制,否则立即调整大小可能是最有意义的。正如您所说,与增量调整大小相比,它将缩短查找时间,并且通常会分摊插入和删除的成本。增量调整大小更适用于所有操作都必须在固定且严格限制的时间内进行的情况。

Unless you have tight time constraints on every hash table operation, resizing immediately probably makes the most sense. As you say, it will improve lookup times over incremental resizing, and just generally amortize the cost of insertion and deletion. Incremental resizing is more applicable to cases where all operations have to proceed in a fixed and strictly bounded amount of time.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文