Is a hash table a good data structure for storing data in an application that support partial search such as "select * from MyTable where name like 'John%'. If not, what is?

I would have thought that hash table isnt ideal because there no way to make faster than O(n). Maybe a some kind of balanced binary tree best. However, I am not sure that it would be best for the particular query above.

  • $\begingroup$ What are your thoughts? Have you tried to figure out how to implement such queries? This seems like a good test of your understanding of hashtables and what operations they support. You should be able to answer this on your own if you understand how hashtables work, so I suggest spending some more time to try to solve this on your own, then edit the question to show your thoughts and what prevents you from answering it on your own, so we understand your current level of understanding. $\endgroup$
    – D.W.
    Apr 27, 2021 at 19:48
  • $\begingroup$ @D.W. edited now $\endgroup$
    – Trajan
    Apr 28, 2021 at 10:22
  • $\begingroup$ So what question do you want answered? The question you articulate is whether a hash table is good, and you seem to have answered your own question. Is your real question what data structure would be a good choice for these queries? If so, please edit your question to ask that question instead. $\endgroup$
    – D.W.
    Apr 28, 2021 at 17:34


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.