Click here to Skip to main content
15,894,405 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi friends

i want to develop a dictionary that take a constant time to search meaning of every length words..

plz send me solution..
Posted
Comments
Albert Holguin 16-Jan-12 15:57pm    
What does "every length words" mean? ...and we may help you...but pretty sure no one will send you the solution. Sorry!

See here[^].
 
Share this answer
 
My understanding of the performance of general-purpose hash-tables (dictionaries): you can't get constant access time.
A simple counter example: If you are unfortunate enough that all keys map to the same "index" location, you have to do collision handling all entries.

If your hash table is contraint, e.g. a key word list for a computer language, you can tailor your hash algoritm (key calculation and hash size) so that you have a guaranted first hit or a failure.

I did that exercise once in the distant past in some Verilog compiler development (in C++). I had a set of key words, the key algoritm was such that the first 8 characters or so were mangled by simple operations into an integer.
With a perl script I calculated a hash table size once at development time by brute force such that each key modulo hash-table-size gave a unique index, and the table-size was in the accepted size range.

With that you had a first hit or none, and with the hit, the string had to be compared. Close enough to almost constant access time (worst case time: longest word to compare, where the last character differs to the longes keyword - neglectable).

Cheers

Andi
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900