hashtable - Which data structure to add/look up/keep count of strings? -


I am trying to figure out which data structure is to support the following tasks faster: < / P>

  • Add a string (if it is not there, add it, if it is, raise a counter for the word)
  • Mark a given string ( Look through the string and then read the counter)

I am debating between a hash table or a trilogy. I understand to see a hash table fast and as long as you add to avoid collision. If I do not know ahead of time, will I have a better way of going?

It really depends on the type of stars that you use as a "key" Going. If you are using excessive variable strings, plus you do not have a good hash algorithm for your strings, then a trio can beat a hash.

However, given a good hash, the lookup will be greater in a trilogy (given the very bad hash given, the opposite is true, though.) If you do not know your input, but a decent hashing Algorithm, I personally prefer to use a hash.

In addition to this, most modern languages ​​/ frameworks are very good hashing algorithms, so there are possibilities, you will be able to implement a good lookup using a hash with very little work, which is quite good will do.


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -