Consider a hash table $$\texttt{T[m]}$$ ($$m$$ is a constant) in which collisions are handled by separate chaining so those collide elements are added to a queue.

  • Give the declaration of the data structure to use.
  • Write a function that adds an element to T; use exclusively the ADT operations of lectures.

 


Difficulty level
Video recording
This exercise is mostly suitable for students
typedef queue hashtable[M];

int insert(hashtable h, int nb)
{
    return EnQueue(&h[hash(nb)], nb);
}

Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Topological sort using BFS traversal of a graph using an adjacency matrix