Constructing a tree
-
Dear everyone; I have got a pure C++/ algorithmic question that i would appreciate your input towards. I have a number of files (lets say 100 files) of similar input formats. To reduce the complexity of the problem I will give you a simplied example: File 1: File 2: File 3: A A B B E A C D D D D F E F E I want to write a program which produces a tree from the files, in which the first node is the node from the first line (from above) with the highest number of occurences ('A' in this case). Consequently File 3 will be ignored. The resulting tree will be something like A (100%) B (50%) E (50%) C (50%) D (50%) D (100%) E (50%) E (50%) SO basically the program should go through the files and construct a tree with a % value of each node. every time branching occurs the % will be divided depending on the number of children. My question is, is there any specific algorithm / similar algorithms which i can use to overcome this problem ? and What's the best way to visualise the tree? Your help is very much appreciated Best Regards
llp00na
-
Dear everyone; I have got a pure C++/ algorithmic question that i would appreciate your input towards. I have a number of files (lets say 100 files) of similar input formats. To reduce the complexity of the problem I will give you a simplied example: File 1: File 2: File 3: A A B B E A C D D D D F E F E I want to write a program which produces a tree from the files, in which the first node is the node from the first line (from above) with the highest number of occurences ('A' in this case). Consequently File 3 will be ignored. The resulting tree will be something like A (100%) B (50%) E (50%) C (50%) D (50%) D (100%) E (50%) E (50%) SO basically the program should go through the files and construct a tree with a % value of each node. every time branching occurs the % will be divided depending on the number of children. My question is, is there any specific algorithm / similar algorithms which i can use to overcome this problem ? and What's the best way to visualise the tree? Your help is very much appreciated Best Regards
llp00na
llp00na wrote:
File 1: File 2: File 3: A A B B E A C D D D D F E F E
You've not used alignment correctly (use the <pre> tags) so I'm unclear as to what the three files look like.
llp00na wrote:
Consequently File 3 will be ignored.
Why?
llp00na wrote:
The resulting tree will be something like A (100%) B (50%) E (50%) C (50%) D (50%) D (100%) E (50%) E (50%)
Does this tree branch to the right, or does it branch downward? Again, alignment would make the difference here.
llp00na wrote:
SO basically the program should go through the files and construct a tree with a % value of each node. every time branching occurs the % will be divided depending on the number of children.
What exactly does this mean? Use percentages other than 100 and 50 so that we can see how the files relate to the nodes.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb