b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

哈夫曼树带权路径长度_c 哈夫曼树编码_数据结构哈夫曼树编码(3)

电脑杂谈  发布时间:2017-03-01 10:05:02  来源:网络整理

q=p->parent->parent; /*然后把它们从链表中删掉*/

t=(struct tree*)malloc(sizeof(struct tree));

t->lchild=p; /*频度:左儿子<=右儿子*/

t->rchild=p->parent;

t->m=p->m+p->parent->m;

t->rchild->parent=t;

t->rchild->sign=1;

t->lchild->parent=t;

t->lchild->sign=0;

t->sign=-1;

root=t; /*root为根结点*/

root->parent=NULL;

if(q!=NULL){ /*判断链表是否为空*/

head=q;

r=head;

e=head; /*把新生成的根结点插入到链表中去*/

if(head->m>t->m){ /*判断是否为头节点*/

t->parent=q;

head=t;

}

else{

r=r->parent;

while(r!=NULL&&r->m m){

e=r;

r=r->parent;

}

t->parent=r;

e->parent=t;

}

p=head;

root=t;

}

else break; /*如果链表为空则结束*/

}

}

/******************************编码******************************/

void ccode(){

struct tree *p,*q;

int j;

printf(" codes as follows: characters code ");

for(j=0;j<size;j++){ p="" <="">

head=NULL;

p=ps[j]; /*从叶到根求编码*/

printf("%c ",p->data);

while(p->parent!=NULL){ /*把编码存入栈中*/

q=(struct stack *)malloc(sizeof(struct stack));

q->data=p->sign;

q->next=head;

head=q;

p=p->parent;

}

q=head; /*输出编码*/

while(q!=NULL){

printf("%d",q->data);

q=q->next;

}

printf(" ");

}

}

/******************************译码******************************/

char translate(){

struct tree *r,*p,*q;

int n;

char c;

/*读取01序列*/

Error: printf(" Input codes consist of 0 and 1 (end of ENTER): ");

n=get);

if(n!= ){ /*读取第一个字符*/

p=(struct tree*)malloc(sizeof(struct tree));


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-35162-3.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    • 裴澈
      裴澈

      敢独立就可以挂上五星红旗

    • 易俊阳
      易俊阳

      总在说数量

    • 鲁共公姬奋
      鲁共公姬奋

      不行了不行了我受不了新表情的诱惑了还有四天我就升级

    热点图片
    拼命载入中...