In CLRS excise 22.1-8 (I am self learning, not in any universities)
Suppose that instead of a linked list, each array entry Adj[u] is a hash table conta
Questions 3 and 4 are very open. Besides the thoughts from other two, one problem with hash table is that it's not an efficient data structure for scanning elements from the beginning to the end. In a real world, sometimes it's pretty common to enumerate all the neighbors for a given vertex (e.g., BFS, DFS), and that somehow compromises the use of a direct hash table.
One possible solution for this is to chain existing buckets in hash table together so that they form a doubly-linked list. Every time a new element is added, connect it to the end of the list; Whenever an element is removed, remove it from the list and fix the link relation accordingly. When you want to do an overall scan, just go through this list.
The drawback of this strategy, of course, is more space. There is a two-pointer overhead per element. Also, the addition/removal of an element takes more time to build/fix the link relation.
I'm not too worried about collisions. The hash table of a vertex stores its neighbors, each of which is unique. If its key is unique, there is no chance of collision.
It depends on the hash table and how it handles collisions, for example assume that in our hash table each entry points to a list of elements having the same key.
If the distribution of elements is sufficiently uniform, the average cost of a lookup depends only on the average number of elements per each list(load factor). so the average number of elements per each list is n/m where m is the size of our hash table.
The answer to question 3 could be a binary search tree.
In an adjacency matrix, each vertex is followed by an array of V elements. This O(V)-space cost leads to fast (O(1)-time) searching of edges.
In an adjacency list, each vertex is followed by a list, which contains only the n adjacent vertices. This space-efficient way leads to slow searching (O(n)).
A hash table is a compromise between the array and the list. It uses less space than V, but requires the handle of collisions in searching.
A binary search tree is another compromise -- the space cost is minimum as that of lists, and the average time cost in searching is O(lg n).