The general program realizes to add the data information, establishes the open hash list, the closed hash list, the hashing and the closed hashing search, the time performance analysis, as well as the overflow table establishment and the search these functions.
The following is a separate description of the principle:
Open a hash list: the use of single linked table storage mode, does not produce accumulation phenomenon, but because of the addition of pointer fields and increased space overhead.
Closed-list: The use of sequential table storage, storage efficiency is high, but easy to generate accumulation, find difficult to achieve, need to use two times to find.
Overflow table: The combination of open and closed hashing, the first sequence table holds similar pointer fields, and the second one stores overflow.
Realize:
#include <iostream> #include <cstdio> #include <stdio.h> #include <stdlib.h> #define HASHSIZE 53
#define MaxSize using namespace std;
typedef struct {int key;
int si;
} HashTable1;
void CreateHashTable1 (HashTable1 *h,int *a,int num)//hash table linear detection in hashes; {int i,d,cnt;
for (i=0; i