hi ppl...
my code saves a tree in this format in a file:
consider this convention: word before = sign is a node, after the = sign is the value of a branch of this node, after : is the value of this node...
e.g. the file contents below would look like this:
Code:
(pat)
/ \ \
none some full
/ \ \
NO YES (hun)
/ \
yes no
/ \
(type) NO
/ / \ \
Code:
pat = none : NO
pat = some : YES
pat = full :
hun = yes :
type = burger : YES
type = french : NO
type = italian : NO
type = thai :
fri = yes : YES
fri = no : NO
hun = no : NO
i hope you get the above...now i have no idea how to read the file to make the same tree...although i want to make a simpler tree because i just need it to be able to traverse it to check answer...e.g. if i say to the program that pat is full, and hun is yes, and type is italian then the output should be NO according to the tree...
what's the best possible way to do this? is it really necessary to read it as a tree with all nodes etc etc...cause like i said i just need to know what is connected to what and what values it has for which branches...then i can traverse the tree according to this scheme (for above example)...
Code:
//What is the value of pat? (user: full)
//if there are no connections (children) for branch full then stop else
//what is the value of node connected to full branch?
etc etc
Regards,
Farooq