Chain hash table

Chain hash table

This is a hash table implementation. Here collisions are handled by Chaining.The divisor used is 13. A double Array is used for implementation ie Array of pointers.

1 // Authors:- Prerit Goel and Anant Sinha 2 #include 3 struct node 4 { 5 int data; 6 struct node *next; 7 }; 8 struct node *bucks [13] ; 9 10 void addtolist(int,int); 11 void printlist(void); 12 int search_list(int,int); 13 void dell(int); 14 main() 15 { 16 int i,j,k,h,r,flag; 17
<13;i++) 20 { 21 printf(" Enter any number: "); 22 scanf("%d",&k); 23 h=k%13; 24 addtolist(h,k); 25 26 } 27 printlist(); 28 printf(" Enter an element to be searched : "); 29 scanf("%d",&j); 30 r=j%13; 31
data=data1; 58 if(q=NULL) 59 { 60 q=r; 61 q->next=temp; 62 bucks [index] =q; 63 } 64 else 65 { 66 while(temp->next!=NULL) 67 { 68 temp=temp->next; 69 } 70 71 temp->next=r; 72 r->next=NULL; 73 } 74 } 75 void printlist(void) 76 { 77 struct node *p; 78 int i,d; 79 for(i=0;i"><13;i++) 80 { 81 printf(" "); 82 83 p=bucks [i] ; 84 85 while(p!=NULL) 86 { 87 d=p->data; 88 printf("%d -> ",d); 89 p=p->next; 90 } 91 } 92 } 93 94 int search_list(int index, int data) 95 { 96 struct node *p; 97 p=bucks [index] ; 98 if(p=NULL) 99 return 0; 100 else 101 { 102 while(p!=NULL) 103 { 104 if(p->data=data) 105 return 1; 106 else 107 p=p->next; 108 } 109 return 0; 110 } 111 } 112 113 void dell(int data) 114 { 115 struct node *old,*temp,*q; 116 int f,x; 117 f=data%13; 118 q=temp=bucks [f] ; 119 x=search_list(f,data); 120 if(x=0) 121 { 122 printf(" ELement not present"); 123 return; 124 } 125 else 126 { 127 while(temp!=NULL) 128 { 129 if(temp->data=data) 130 { 131 if(temp=q) 132 { 133 q=temp->next; 134 free(temp); 135 return; 136 } 137 else 138 { 139 old->next=temp->next; 140 free(temp); 141 return; 142 } 143 } 144 else 145 { 146 old=temp; 147 temp=temp->next; 148 } 149 150 } 151 } 152 }


Wikimedia Foundation. 2010.

Игры ⚽ Поможем решить контрольную работу

Look at other dictionaries:

  • Hash table — Not to be confused with Hash list or Hash tree. Unordered map redirects here. For the proposed C++ class, see unordered map (C++). Hash Table Type unsorted dictionary Invented 1953 Time complexity in big O notation Average Worst case Space …   Wikipedia

  • Hash list — In computer science, a hash list is typically a list of hashes of the data blocks in a file or set of files. Lists of hashes are used for many different purposes, such as fast table lookup (hash tables) and distributed databases (distributed hash …   Wikipedia

  • Page table — A page table is the data structure used by a virtual memory system in a computer operating system to store the mapping between virtual addresses and physical addresses. Virtual addresses are those unique to the accessing process. Physical… …   Wikipedia

  • Linear hash — Linear Hashing is a dynamic hash table algorithm invented by Witold Litwin (1980) [ Citation | first1=Witold | last1=Litwin | title=Linear hashing: A new tool for file and table addressing | journal=Proc. 6th Conference on Very Large Databases |… …   Wikipedia

  • Cryptographic hash function — A cryptographic hash function (specifically, SHA 1) at work. Note that even small changes in the source input (here in the word over ) drastically change the resulting output, by the so called avalanche effect. A cryptographic hash function is a… …   Wikipedia

  • Rainbow table — A rainbow table is a lookup table offering a time memory tradeoff used in recovering the plaintext password from a password hash generated by a hash function, often a cryptographic hash function. A common application is to make attacks against… …   Wikipedia

  • Rainbow Table — Die Rainbow Table (zu Deutsch: Regenbogentabelle) ist eine von Philippe Oechslin entwickelte Datenstruktur, die eine schnelle, probabilistische Suche nach einem Element des Urbilds (i. d. R. ein Passwort) eines gegebenen Hashwerts… …   Deutsch Wikipedia

  • Rainbow-Table — Die rainbow table (zu Deutsch: Regenbogentabelle) ist eine von Philippe Oechslin entwickelte Datenstruktur, die eine schnelle, probabilistische Suche nach Hash Werten ermöglicht. Der sogenannte Time Memory Tradeoff gestattet die Suche nach fast… …   Deutsch Wikipedia

  • Rainbow table — Die rainbow table (zu Deutsch: Regenbogentabelle) ist eine von Philippe Oechslin entwickelte Datenstruktur, die eine schnelle, probabilistische Suche nach Hash Werten ermöglicht. Der sogenannte Time Memory Tradeoff gestattet die Suche nach fast… …   Deutsch Wikipedia

  • Coalesced hashing — example. For purposes of this example, collision buckets are allocated in increasing order, starting with bucket 0. Coalesced hashing, also called coalesced chaining, is a strategy of collision resolution in a hash table that forms a hybrid of… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”