Câu hỏi phỏng vấn Trees
Câu hỏi

Why is a Hash Table not used instead of a B-T...

Câu trả lời

There are several key reasons why databases typically use B-Trees instead of hash tables for indexing:

  1. B-Trees support range queries and ordered access, while hash tables only support equality lookups. With a B-Tree, you can efficiently find all records between two values, or the first N records in sorted order. Hash tables cannot do this[1][2].

  2. B-Trees have better worst-case performance. Hash table lookups are O(1) on average, but can degrade to O(n) if there are many collisions. B-Tree lookups are O(log n) in the worst case[1][2].

  3. B-Trees are more space efficient. Hash tables need to allocate extra space for the hash array, and performance degrades if the load factor gets too high. B-Trees only store what they need[2].

  4. B-Trees are more robust to memory constraints. If data doesn't fit in memory, B-Trees can efficiently page data in and out from disk. Hash tables require the entir...

expert

expert

Gợi ý câu hỏi phỏng vấn

middle

What is the difference between Tree Depth and Height?

expert

What are the differences between B trees and B+ trees?

junior

What is Height and Depth of a Tree and its Nodes?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào