Which is faster, Hash lookup or Binary search?

后端 未结 17 2571
你的背包
你的背包 2020-12-02 06:47

When given a static set of objects (static in the sense that once loaded it seldom if ever changes) into which repeated concurrent lookups are needed with optimal performanc

17条回答
  •  一个人的身影
    2020-12-02 06:52

    I wonder why no one mentioned perfect hashing.

    It's only relevant if your dataset is fixed for a long time, but what it does it analyze the data and construct a perfect hash function that ensures no collisions.

    Pretty neat, if your data set is constant and the time to calculate the function is small compared to the application run time.

提交回复
热议问题