I want to be able to go through a loop with if statements that will store a set of data. After the first loop gets its values I want to make a loop that goes through the list of values just created. In that loop there will be if statements that add children to the respect current digit in the list. Also each child will add the value of its respective parent. After that occurs the program will go through another loop adding a set of children to each new child previously dynamically made. The new set of children will add the value of the respected parent to there current value.
Some nodes may have 0 children some could have as many as 100. After the tree is created I need to go back through and compare each set of children for each parent and set the respective child sets value that I find to the parent, until eventually the root value will be determined.
Below is a generic outline of part of sort of what I am looking to do.
Basically i'm looking to make a dynamic tree(or any structure that works), then compare its values and find one root optimal value. Any suggestions/ help is welcome, I can't seem to rap my head around how to do this.
class Program
{
static void Main(string[] args)
{
List<int> numbers = new List<int>();
for (int i = 0; i <= 7; i++)
{
for (int j = 0; j <= 7; j++)
{
if (j == 4 || j == 2)
{
numbers.Add(j);
}
}
}
Console.WriteLine();
foreach (int x in numbers)
{
for (int i = 0; i <= 7; i++)
{
for (int j = 0; j <= 7; j++)
{
if (j == 4 || j == 2)
{
// add a child to the current digit
// add current digit to its child
}
}
}
}
// for loop to go through all children just created
// repeat similar process process add parent number to all respective children values
//repeat this process n number of times
Console.Read();
}
}