Try to write a search algorithm

So I recently have an assignment, which is my final project, to search for a word in multiple documents. In which contains about 5000 words.( Score bases on the time of the search and the time to load up file ).

There are so many thing I thought of but this is my final result. Because I don't want to try to write it for a month to find out it's not possible.
Can you guys give me advices for my idea.

So I think i gonna use a 2-3-4 tree( because B-tree is too hard for me ). The trick is I gonna put the tree in the Node and vice versa.( Code below for those who cant imagine it ).
1
2
3
4
5
6
7
8
9
10
11
12
13
14
  class Tree
 {
   Node* _root;
     public :
   .....
 }

   class Node
 {
  Char _letter; or string _word // I haven't decided to store each char or a whole word
  Tree _subTree;
     public:
   ....
 }

That's my plan for now. Any advice on the run time or the code could be helpful.
Fix me on my coding style too if it's too messy or hard to understand or what shoud a good coding style be.
Thank you guys ^^
Hm, apologies if there's an obvious reason against this, but why not store the words in a HashMap? Would be faster to access than in a tree I think. Also, take a look at inverted index data structure: http://nlp.stanford.edu/IR-book/html/htmledition/an-example-information-retrieval-problem-1.html a standard data structure in information retrieval.
hm, The teacher clearly instructed that i must use tree as data structure for my program.
I read through the link you gave me though, gave me some more ideas on what im about to do :3

Last edited on
Topic archived. No new replies allowed.