Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> Python

Cơ chế tìm kiếm (searching) trong Python Dictionary

Dict là hash table. Lookup key gần như constant time (amortized O(1)), bất kể size. Tạo hash của key, tìm vị trí bucket. Nếu collision → chạy collision resolution algorithm.

Trade-off: dict tốn nhiều memory hơn do sparse structure.