Skip to content

Instantly share code, notes, and snippets.

@ochilab
Last active November 17, 2020 08:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ochilab/e1fb38099e3fc52eef36cb5193d19262 to your computer and use it in GitHub Desktop.
Save ochilab/e1fb38099e3fc52eef36cb5193d19262 to your computer and use it in GitHub Desktop.
ハッシュ法におけるチェイン法の実装
Node *SearchChainNode (Hash *h, Data x){
int key = hash(x.no);/* 探索するデータのハッシュ値 */
Node *p = h->table[key]; /* 着目ノード */
while (p != NULL) {
if (p->data.no == x.no) /* 探索成功 */
return (p);
p = p->next; /* 後続ノードに着目 */
}
return (NULL); /* 探索失敗 */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment