zoukankan      html  css  js  c++  java
  • HashMap Collision Resolution

    Separate Chaining

    Use data structure (such as linked list) to store multiple items that hash to the same slot

    1. use linked list
    Collision: insert item into linked list
    Find: compute hash value, then do Find on linked list

    2. use BST
    O(log N) time instead of O(N). But lists are usually small - not worth the overhead of BSTs

    Open addressing (or probing or Closed Hashing)

    Search for other slots using a second function and store items in first empty slot that is found

    Separate chaining can take up a lot of space...

    Given an item X, try cells h0(X), h1(X), h2(X), .., hi(X)
    hi(X) = (Hash(X) + F(i)) mod TableSize
    (Define F(0) = 0)

    Linear: F(i) = i
    Quadratic: F(i) = i2
    Double Hashing: F(i) = i * Hash2(X)

    details

  • 相关阅读:
    普通变量和数组作为函数参数的区别
    2.1
    SQL NULL 值
    SQL ALTER TABLE 语句
    SQL CHECK 约束
    SQL LEFT JOIN 关键字
    SQL JOIN
    SQL Alias(别名)
    SQL 通配符
    从暴力中解脱,
  • 原文地址:https://www.cnblogs.com/ireneyanglan/p/4951765.html
Copyright © 2011-2022 走看看