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

1 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Large 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