Skip to content

Zoom sur le code

Loic Humbert edited this page May 31, 2017 · 7 revisions
while (binaryTree.Nodes.Count > 1)
           {
               var weight = binaryTree.Nodes[0].Weight + binaryTree.Nodes[1].Weight;
               binaryTree.Nodes.Add(new Node(binaryTree.Nodes[0], binaryTree.Nodes[1], weight));
                // Debug
               //Console.WriteLine("min1:" + binaryTree.Nodes[0].letter);
               //Console.WriteLine("min2:" + binaryTree.Nodes[1].letter);
                // Supprimer les noeuds assemblés
               binaryTree.Nodes.Remove(binaryTree.Nodes[1]);
               binaryTree.Nodes.Remove(binaryTree.Nodes[0]);
                // Trier et afficher
               binaryTree.SortNodesByWeight();
                binaryTree.PrintWeights();
          }
Clone this wiki locally