naobe @ ウィキ

アルゴリズム

最終更新:

naobe

- view
管理者のみ編集可

トポロジカルソート


閉路のない有向グラフ(Directed Acyclic Graph)(DAG)をソートする。結合ノードごとに経路をソートする。ジョブの実行順序を求めるために使う。

ハッシュ

SDBM


sdbm(ndbmのpublic domain reimplimentation)データベースライブラリ用に作成された。ビットスクランブルが良い。
実質の機能は、hash(i) = hash(i - 1) * 65599 + str[i]。バークレーDBでは以下のアルゴリズムを使っている、

   static unsigned long
   sdbm(str)
   unsigned char *str;
   {
       unsigned long hash = 0;
       int c;
  
       while (c = *str++)
           hash = c + (hash << 6) + (hash << 16) - hash;
  
       return hash;
   }
人気記事ランキング
ウィキ募集バナー