Write a function that searches for a key in a hash table using coalesced hashing with 2 separated zones.
![](ressourceimages/ts7-01.png)
We assume the existence of a hash function $$\texttt{int h(element e)}$$ and a function $$\texttt{is_empty}$$ that determines whether an entry of the hash table is empty or not.
Difficulty level
![](images/star4.png)
Video recording
This exercise is mostly suitable for students
int search_coalesced(hashtable T, int m, element e)
{
int v =hash_function(e) ;
if (empty(T,v)) return 0 ;
if (strcmp(T[v].data,e)==0) return 1 ;
while (T[v].link != -1 && strcmp(T[v]. data ,e))
v = T[v].link ;
if (strcmp(T[v]. data ,e)) return 0 ;
return 1 ;
}
Back to the list of exercises
Looking for a more challenging exercise, try this one !!
![](images/star5.png)