如何理解哈夫曼树
/*构造哈夫曼树的n-1个非叶节点*/for (i = 0; i < n - 1; i++)
{
m1 = m2 = MaxValue;
x1 = x2 = 0;
for (j = 0; j < n - 1; j++)
{
if (haffTree[j].weight < m1&&haffTree[j].flag == 0)
{
m2 = m1; //此处赋值
x2 = x1;
m1 = haffTree[j].weight;
x1 = j;
}
else if (haffTree[j].weight < m2&&haffTree[j].flag == 0) //那么此处不就是和上面的判断一样吗这里的m2等于上面的m1,最后怎么的出两个最小的权值呢?
{
m2 = haffTree[j].weight;
x2 = j;
}
}