云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > 基于matlab构造最优二叉树

基于matlab构造最优二叉树

  • 62 次阅读
  • 3 次下载
  • 2026/4/27 19:36:06

xxxx20xx届本科生毕业设计(论文)

disp('% p is a vector with the probability'); disp(p');

ltr=length(tr);% augment with the growing of the huffman tree lp=length(p);% decrease with the growing of huffman tree roolp=3; while lp>1

%if(length(list)-lp+1 <= 9)

%subplot(roolp,roolp,length(list)-lp+1); figure(length(list)-lp+1); drawhufftree(tr,list,tempp); %end

% merge p(lp) and p(lp-1); p(lp-1)=p(lp-1)+p(lp); p=p(1:lp-1);

% tr(ltr+1) is a new node of the huffman tree

% tr(find(tr==lp)) and tr(find(tr==lp-1)) is its two children ltr=length(tr); tr(find(tr==lp))=ltr+1; tr(find(tr==lp-1))=ltr+1; tr(ltr+1)=lp-1;

tempp(ltr+1)=p(lp-1); % record the probability of this node % sort p again after merging; pp=-p; [pp t]=sort(pp); p=-pp; %[p,t]=sort(p,'descend'); lp=length(p);

% tempp(1:lp-1)=p(1:lp-1); % update the order of probability to display % update the pointer of tr then temp=tr; for j=1:lp

tr(find(temp==t(j)))=j; end

%show the middle result disp('tr:(huffman tree)'); disp(tr');

disp('tempp:(probability on the tree)'); disp(tempp');

13

xxxx20xx届本科生毕业设计(论文)

disp('p:(probability)'); disp(p');

disp('t:(sort of p)'); disp(t'); end

tr(length(tr))=0; % the root of huffman tree %draw the result

figure(length(list)-lp+1); drawhufftree(tr,list,tempp); end

经过matlab的仿真可得到如下最优二叉树图形:

图4-1 最优二叉树仿真图(1)

14

xxxx20xx届本科生毕业设计(论文)

图4-2 最优二叉树仿真图(2)

15

xxxx20xx届本科生毕业设计(论文)

图4-3 最优二叉树仿真图(3)

16

搜索更多关于: 基于matlab构造最优二叉树 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

xxxx20xx届本科生毕业设计(论文) disp('% p is a vector with the probability'); disp(p'); ltr=length(tr);% augment with the growing of the huffman tree lp=length(p);% decrease with the growing of huffman tree roolp=3; while lp>1 %if(length(list)-lp+1 <= 9) %subplot(roolp,roolp,length(list)-lp+1); figure(length(list)-lp+1); drawhufftree(tr,li

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com