I am reading an article on Hash tables. Here is the text snippet.
A hash table is useful for any graph theory problem where the nodes have real names instead of numbers. Here, as the input is read, vertices are assigned integers from 1 onwards by order of appearance. Again, the input is likely to have large groups of alphabetized entries. For example, the vertices could be computers. Then if one particular installation lists its computers as ibm1, ibm2, ibm3, . . . , there could be a dramatic effect on efficiency if a search tree is used.
My quesitons on above text
What does author mean "as input is read, verticies are assigned integers from 1 onward" don't we have calculate hash key for input read?
What does author mean by "there could be a dramatic effe开发者_如何学Goct on efficiency if a search tree is used."?
How hash tables are helpful in graph theory problems when compared to search tree?
Thanks!
(1) It's a map not a set, they calculate a hash value of course, but the node is mapped to an integer, and that's the purpose of the map.
(2) A search tree is O(logn) search, using a map based on search tree will increase time complexity of all ops *O(logn). [for example, BFS will take O(logV*[V+E))
instead of O(V+E)
, because of the lookup time.
(3) Hash table is O(1), so time complexity will be better for hash tables, in the average case.
(1) the author could be referencing methods of representing graphs in matrix form, like this example
(2) not sure about "search trees", though if you can represent hash tables as a graph, then there are some methods to optimize them, like this example.
精彩评论