Need a program for dictionary which works on Complexity of O(1) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Need a program for dictionary which works on Complexity of O(1)

Dictionary with least complexity

14th Feb 2017, 1:23 PM
sai bhaskar
sai bhaskar - avatar
1 Answer
0
real time? thats almost impossible..... you could read in a file words.txt got em all then hash all the words that start with a into a linked list. so hash fun would be word[0] % 26. then when searching for the word. you begin at that letter instead of the beginning of the alphabet. but for it to be O (1) you would have ro hash every word individually with a unique key. then just recall that key.
19th Feb 2017, 7:44 PM
Michael Szczepanski
Michael Szczepanski - avatar