標(biāo)題:動(dòng)態(tài)哈夫曼編碼的改進(jìn) | ||
《計(jì)算機(jī)世界月刊》1994年7月號(hào)所登載的《動(dòng)態(tài)哈夫曼編碼的數(shù)據(jù)壓縮方法》一文給出了一種實(shí)時(shí)性較強(qiáng)的數(shù)據(jù)壓縮方法,該方法的最大特點(diǎn)是不需預(yù)先對(duì)原始數(shù)據(jù)進(jìn)行一遍掃描以建立哈夫曼樹,而改為以動(dòng)態(tài)變化的哈夫曼樹對(duì)數(shù)據(jù)編碼。 該文所附的動(dòng)態(tài)哈夫曼編碼數(shù)據(jù)壓縮與解壓源程序中的update函數(shù)是動(dòng)態(tài)修改哈夫曼樹的關(guān)鍵部分,該函數(shù)對(duì)動(dòng)態(tài)哈夫曼樹的一種可能情況無法正確修改,針對(duì)這一點(diǎn),本文附上對(duì)該函數(shù)的一個(gè)修正定義,以使該壓縮與解壓程序更加完善。 以下就舉例說明原update函數(shù)無法正確修改的一種哈夫曼樹。例如若要壓縮“tthhis”字符串,則在壓縮完“tth”之后的動(dòng)態(tài)哈夫曼樹為圖所示(設(shè)根結(jié)點(diǎn)序號(hào)為1000): @@04a07700.gif;圖壓縮完“tth”之后的動(dòng)態(tài)哈 ……(快文網(wǎng)http://hoachina.com省略580字,正式會(huì)員可完整閱讀)……
if(temp->front!=null) { tempa=temp; while(temp->front!=null) temp=temp->front; if(temp==tempa->parent) { tempa->weight++; tempa->after=tempa->front=null; temp->after=null; insertweight(tempa); } else { pointer=temp->leftchild; if(pointer!=null) pointer->parent=tempa; temp->leftchild=tempa->leftchild; if(temp->leftchild!=null) temp->leftchild->parent=temp; tempa->leftchild=pointer; pointer=temp->rightchild; if(pointer!=null) pointer->parent=tempa; temp->rightchild=tempa->rightchild; if(temp->rightchild!=null) temp->rightchild->parent=temp; tempa->rightchild=pointer; letter=temp->letter; temp->letter=tempa->letter; tempa->letter=letter; if((tempa->leftchild==null)&&(tempa->rightchild==null) { b=leaf; while(b!=null) { if(b->charnode==temp) { b->charnode=tempa; break; } elseb=b->next; } } if((temp->leftchild==null)&&(temp->rightchild++null)) { b=leaf; while(b!=null) { ……(未完,全文共2506字,當(dāng)前只顯示1508字,請(qǐng)閱讀下面提示信息。收藏動(dòng)態(tài)哈夫曼編碼的改進(jìn)) 上一篇:微機(jī)unix直接視頻圖形程序設(shè)計(jì) 下一篇:_與傳統(tǒng)兵家智慧 |