Order preserving minimal perfect hash functions

感情迁移 提交于 2019-12-23 20:33:03

问题


I want to implement an OPMPH function for the words in a dictionary in C++. How do I do it?

Thanks!


回答1:


Have you looked at these papers?

  • http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.84.4018&rep=rep1&type=pdf
  • http://dx.doi.org/10.1016/0020-0190(92)90220-P (the short form link that leads to a very long link at http://www.sciencedirect.com/)
  • http://eprints.cs.vt.edu/archive/00000248/01/TR-91-01.pdf



回答2:


Limit your word length to 6 letters or less and you might be able to make it work. Not very practical.




回答3:


If you need alphabetical order use a Trie or a DAWG (like I recommended in your last question). For an order besides alphabetic I would use a binary tree (std::map in C++ is implemented with a red-black tree usually).

Implementing an order preserving hash container sounds like the mother of all early optimizations.



来源:https://stackoverflow.com/questions/1959438/order-preserving-minimal-perfect-hash-functions

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!