#include #include #include #include #define INPUT_SIZE 1000000 struct hashentry { int value; struct hashentry *previous; struct hashentry *next; }; struct hashentry *hashtable[INPUT_SIZE]; void makehash(int []); int hashthis(int); void print_column(int); int find_element(int); int main() { struct hashentry test1, test2; struct hashentry *test; int inputs[INPUT_SIZE]; int i, result; double en, st; double sum=0.0; double microseconds = 1000000.0; struct timeval start_time, stop_time; srand(getpid()); for (i=0; inext=NULL; hashtable[i]->previous=NULL; hashtable[i]->value=-1; } for (i=0; ivalue != -1) hash_pointer=hash_pointer->next; hash_pointer->value=array[i]; hash_pointer->next=(struct hashentry *) malloc(sizeof(struct hashentry)); hash_pointer->next->next=NULL; hash_pointer->next->previous=hash_pointer; hash_pointer->next->value=-1; } } void print_column(int c) { struct hashentry* headp; for (headp=hashtable[c]; headp->value!=-1; headp=headp->next) printf("%d, ", headp->value); printf("\n"); } int find_element(int element) { struct hashentry* headp; int column; int found=0; column=hashthis(element); for (headp=hashtable[column]; headp->value!=-1; headp=headp->next) { if(headp->value == element) found=1; } return found; }