I had an idea here, but I need to help in some way, or rather push it. I hope you will help me. The idea: For example: You enter the letters "pr", and it shows in the drop-down list all the words from that file, which begin with "pr". How can this be achieved? Nudge me please. Write this if you can, then in C ++, if C # is more efficient, then C #
- So what is the actual question? - karmadro4
|
3 answers
Count the words in specials. tree. Tree nodes contain letters of words.
Example:
п | р | / | \ а я о | | | в м с | | | о о т | о
When a new letter is entered into the list, all resulting subtrees are displayed.
- yes, but how to implement it? This is in my head too, just where to start and how to do it? - navi1893
- 2Do you know how trees are realized? If not, then start by learning about well-known data structures. If yes, then take and write. You define the interface (adding a node, deleting a node, etc.), then a set of classes (
дерево
,узел
, etc.) and writing. - fogbit 2:26 pm - then I better start exploring the trees, right? - navi1893 pm
- If you consider this advice as the most appropriate, then yes. - fogbit
- and what do you advise me to study trees from scratch? - navi1893
|
Do not prematurely optimize and solve the problem in a trivial way (C #):
// Передайте данной функции вашу перечислимую коллекцию со словами - 'words'. public static IEnumerable<string> GetWordsStartingWith( IEnumerable<string> words, string startingWith) { return words.Where(word => word.StartsWith(startingWith)); }
Spend a benchmark with real data. Are you sure that you are not satisfied with the performance?
Then embed in your application any data structure that is designed to work with strings, for example, the suffix tree.
- Continue to experiment with different data structures until the performance starts to suit you or you can prove that you can not get a faster solution in practice.
- It was interesting to read and take what was necessary. Thank! Would you recommend materials for a beginner to be able to work well with <string>, <vector>, classes, trees, like this - navi1893
- @ navi1893
C++ Primer
and Kormen. - Costantino Rupert
|
Take the SQLite database for storing words, pull out the list of sql with a query like select word from words_table where word like 'пр%' limit 1,1000
, screw it to the heir of your combo box.
- and a little more detail you can? How do I think it is to associate with C ++ or C #, yes? More? - navi1893 2:17 pm
- oneThe implementation platform is not fundamental. C # is easier. Read a book on C # (for example, bookwebmaster.narod.ru/csharp.html ), set up a studio, download a scite for C # ( system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki ) - Chad
- and to work with SQLite, advise something? But to be from scratch - navi1893
|