473,503 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

The best data structure to implement a dictionary

11 New Member
Hey everyone, I'm planning to implement a dictionary on C#. I have about 30,000 words in my database( i keep them in access database right now. Maybe we can make a decision about which database it should be. )

a word and a definition may contain from 1 to 25-30 chars.

The search should work like that ; when user types a, the app should find all the words starting with a.

So the algorithms that i thought about are;

1-) Binarysearch will fail, since there might be some duplicate elements.

2-) Binary Search Tree will fail, since i have all the words in ascending order, when i add the words to the tree, it will be an unbalanced tree( more likely a linked list ) So the performance will be O(n)

3-) Ternary Search Tree, dunno yet if i'll be ok to implement a function that finds the word starts with(...)(to find any word when user starts typing something . for example when the user type "hello" it should search for h, he, hel, hell, hello. It will definitely be so fast for finding exact word. ( and also will work fine for misspelling situations )

4-) Or should i use hash tables ?

Could please gimme some ideas. I couldnt make a decision between these things. Which one will be better or is there any other algorithm for dictionaries that you know.

Thanks in advance.
Dec 18 '11 #1
3 7073
kadghar
1,295 Recognized Expert Top Contributor
I would use any SQL data base server with:

Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM dictionary WHERE word LIKE = '[search]%'
Im not quite sure I'd be able to make an algorithm that beats MySQL in this query.
Jan 2 '12 #2
kadghar
1,295 Recognized Expert Top Contributor
Now, on the other hand. if your dictionary is well sorted, you can make a binary search to find the first and the last word that matches.

This range of words will be the one you show to the user and also you'll only be searching inside this range when a new character is written.

Or you can combine this idea with my previous post; perhaps it gives better results.
Jan 2 '12 #3
endazyar
11 New Member
thank you for ur reply, i implemented it with ternary search tree. And dont need to have a database. Just storing the data in text file since the dictionary is well sorted. Ternary search tree also helps it to find the best matched words.
Jan 19 '12 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
332
by: Bob Weiner | last post by:
I'm new to C#. What is the best (in terms of programmability and use) data structure to use to maintain an array of information with containing 3 fields of differing types. For instance:...
3
3160
by: Sigmathaar | last post by:
Hi, I'm need some advice about lists and vectors. I'm doing a program who needs to have sequential access of a non ordered unit of objects whose size decreases almost each time the sequence is...
6
2609
by: James | last post by:
I am using vb.net and need to keep in memory a large data structure, so I am looking for the best option. And after several test I am pretty confused. So I will be grateful if anyone can help me. ...
4
3074
by: LoneHunter01 | last post by:
Basically, I just need a general direction on where to go for this. Yes, this is for a school project, though it's strictly an optional one (and I have tried many solutions, one in-depth). We've...
7
1617
by: bahoo | last post by:
Hi, My data is organized like this, where A always goes from 1 to some number N: A 1 2 3 ... B 53,26 42,18 15,86 ... C 59 43 31 ......
16
6899
by: ravi | last post by:
I want to implement a dictionary data structure with the features features * autocorrect * autocomplete * spellcheck can any body tell me that which data structure will be best for its...
3
4739
by: Djerba | last post by:
Hi, What is the best data structure to use when you have a lot of data to process and you need to later search using different keys. Say you have to store tons of data of this form struct node...
4
2641
by: poojagupta | last post by:
What will be the best data structure to store the huge amount of the data and why?
2
1819
by: nomad | last post by:
I am writing a c++ program and will be implementing a console menu driven prompt. The menu will have several options, and sub-menus may also have multiple options. What is the best data structure...
3
3370
by: dev101 | last post by:
hi fellow coders, what is the best data structure to store a grid / matrix, with 2 Keys (row, col), and the Values (cell entries) can be any object? Similar to a 2-dimensional array, but i am trying...
0
7203
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7281
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7334
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5579
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3156
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1514
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
383
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.