Skip to content

Instantly share code, notes, and snippets.

@torus
Created April 21, 2012 10:08
Show Gist options
  • Save torus/2436326 to your computer and use it in GitHub Desktop.
Save torus/2436326 to your computer and use it in GitHub Desktop.
アルゴリズム・イントロダクション 11.2-4
  • 使用中フラグ
  • 要素
  • next ポインタ

初期化

  • すべての要素のフラグを false にセットする

挿入

  • もし T[h(x)] のフラグが偽なら
    • T[h] に (true, x, nil) を代入
    • そうでなければ、
      • T[h] の要素のハッシュ値と h(x) を比較し、同一なら
        • 次のように操作してチェインにつなげる
          • next ポインタをたどってチェインの終端を探す
          • 未使用の所に (true, x, nil) を代入し、チェインの終端のポインタをそこへ向ける
        • 同一でなければ、
          • T[h] の内容を未使用なところに移動する
          • T[h] に (true, x, nil) を代入
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment