Beispiel #1
0
        public void CreateChild(int child_weight, int child_value)
        {
            FruitNode child = new FruitNode(level + 1, child_weight, value - child_value * child_weight);

            child.parent = this;
            children.Add(child);
        }
Beispiel #2
0
 public FruitNode(int node_level, int node_weight, int node_value)
 {
     level    = node_level;
     weight   = node_weight;
     value    = node_value;
     parent   = null;
     children = new List <FruitNode>();
 }
Beispiel #3
0
 public FruitTree(int root_value, List <int> prices)
 {
     root         = new FruitNode(0, 0, root_value);
     current_node = root;
     leaves       = new List <FruitNode>();
     levels_price = new List <int>();
     foreach (int item in prices)
     {
         levels_price.Add(item);
     }
     next_node_weight = 0;
 }