• 大小: 7KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-06-17
  • 语言: Matlab
  • 标签: 未分类  

资源简介

matlab开发-自适应霍夫曼编码技术字符串。使用树的自适应哈夫曼

资源截图

代码片段和文件信息

function[tre]=complete_tre(tre)
levels=ceil(log2(length(tre)));
totnods=2^levels-1;
for i=length(tre)+1:totnods
    tre{i}=[];
end


%----------%check for testingswap-----------------------
 for count=1:levels
    levels=ceil(log2(length(tre)));
    %finding the nodes array value
    for j=1:length(tre)
        if length(tre{j})==1      %parent
            nodes(j)=tre{j};
        elseif isempty(tre{j}) %nothing 
            nodes(j)=nodes(j-1);
        elseif length(tre{j})==2      %child
            nodes(j)=tre{j}{2};
        end
    end   %built nodes
    %nodes
    node1=0;
    node2=0;
    for j=1:levels-1   %finding node1 and node2 of intra level swaping only
        tempchek=nodes(2^(j-1):2^j-1);
        for i=1:(length(tempchek)-1)
            k=i+1;
            if mod(i2)==1
                if tempchek(i)>tempchek(k)
                    node1=2^(j-1)+i-1;
                    node2=node1+1;
                    break;
                end
            end
         end
    end
    node1;
    node2;

    if node1~=0
        tre=testingswap(tre);
    end

 end
 
 

%-------------------------%check for interlevel-----------------
            levels=ceil(log2(length(tre)));
            %finding the nodes array value
            for j=1:length(tre)
                if length(tre{j})==1      %parent
                    nodes(j)=tre{j};
                elseif isempty(tre{j}) %nothing 
                    nodes(j)=0;
                elseif length(tre{j})==2      %child
                    nodes(j)=tre{j}{2};
                end
            end   %built nodes
            nodes;

            node1=0;
            node2=0;

            for j=1:levels-1   %finding node1 and node2 of intra level swaping only
               if j~=1
                   j;
                   l=nodes(2^(j-2):2^(j-1)-1);
                   a=l(l~=0);
                   prevmin=min(a);
                   minnodenumber=2^(j-2)-1+strfind(nodes(2^(j-2):2^(j-1)-1)prevmin);
                   tempchek=nodes(2^(j-1):2^j-1);
                   thismax=max(tempchek);
                   maxnodenumber=2^(j-1)-1+strfind(tempchekthismax);

                   if length(minnodenumber)>1|length(maxnodenumber)>1
                        continue
                   end

                   if prevmin                       tre=interlevel(tre);
                       break;
                   end

               end
            end

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件        2519  2015-10-21 00:51  Adaptive Huffman\complete_tre.m
     文件         687  2015-10-19 23:36  Adaptive Huffman\get_codes.m
     文件        3204  2015-10-19 23:36  Adaptive Huffman\interlevel.m
     文件        1085  2015-10-21 00:47  Adaptive Huffman\main.m
     文件        1230  2015-10-21 01:09  Adaptive Huffman\README.txt
     文件        1592  2015-10-19 23:36  Adaptive Huffman\testingswap.m
     文件        1270  2015-10-21 00:46  Adaptive Huffman\tree.m
     文件         995  2015-10-21 00:44  Adaptive Huffman\update_tree.m
     文件        1572  2015-10-20 13:24  license.txt

评论

共有 条评论