Is there a way to swap the positions of nodes in a tree?any function, or any other way?

1 回表示 (過去 30 日間)
Samuel Chandu
Samuel Chandu 2016 年 8 月 24 日
I am trying to write the code for modified adaptive huffman coding, in that based on the incoming data the nodes are to be shifted close to the root node if their occurrence is frequent. For example this is my code:
clc;
tr=tree('NYT');
[tr, NYT1]=tr.addnode(1,'0');
[tr, n1]=tr.addnode(1,'node(1).data');
[tr, NYT2]=tr.addnode(2,'0');
[tr, n2]=tr.addnode(2,'node(2).data');
disp(tr.tostring);
the following appears in the command window
NYT
+--------+-----+
! !
0 node(1).data
+----+---+
! !
0 node(2).data
My question is, is there a way to swap the positions of node1 and node2 such that node2 goes up and node1 comes down? http://tinevez.github.io/matlab-tree/
I am going through the above link for understanding the construction and editing a tree. Thanks for your time!

回答 (0 件)

カテゴリ

Help Center および File ExchangeLarge Files and Big Data についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by