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