Write a function that deletes an element of type (char *) from a hash table in which collisions are resolved by applying the hash coalesced with separated zones.


Difficulty level
Video recording
This exercise is mostly suitable for students
int delete_coalesced(hashtable T, int m, element e)
{	int x, v =hash_function(e) ; 
	if (empty(T,v)) 
		return 0 ;
	if (strcmp(T[v].data,e)==0)  
	{	
		if (T[v].link == -1) 
			T[v].link = -2 ;
		else 
			{ x=T[v].link; T[v] = T[x] ; T[x].link = -2 ;}
		return 1 ;
	}
	while (T[v].link != -1 && strcmp(T[v]. data ,e))
		{x = v ; v = T[v].link ;}
	if (strcmp(T[v]. data ,e)) return 0 ;  
	T[x].link = T[v].link ;
	T[v].link = -2 ;
	return 1 ;
}

Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Automata