Which is faster, Hash lookup or Binary search?

后端 未结 17 2587
你的背包
你的背包 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 07:09

    Of course, hash is fastest for such a big dataset.

    One way to speed it up even more, since the data seldom changes, is to programmatically generate ad-hoc code to do the first layer of search as a giant switch statement (if your compiler can handle it), and then branch off to search the resulting bucket.

提交回复
热议问题