Machine-translated by Google. Questions are authored in English.
Top

Discussion

Match each symbol table implementation with its typical lookup cost.
List I
A. unordered linear list
B. balanced search tree
C. hash table
D. hash table with every key colliding
List II
1. near constant on average
2. linear in the entry count
3. linear in the entry count
4. logarithmic in the entry count

  • A.A-4, B-2, C-1, D-3
  • B.A-2, B-4, C-3, D-1
  • C.A-3, B-1, C-4, D-2
  • D.A-2, B-4, C-1, D-3

Answer: D

The comparison is what drives the choice in practice. A hash table wins on average but degenerates to a list in the pathological case, which is why the hash function matters. A well chosen function makes that case vanishingly unlikely in practice.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.