According to the list classes I have some binary and AVL trees. They work the same way like the list but they have got some more functions like find() and a sorted trace() to debug the data. There is also an experiment which shows the difference between both kinds of trees.
[as]import de.je2050.util.tree.Root;
import de.je2050.util.tree.AVLRoot;
import de.je2050.util.data.*;
var bintree: Root = new Root( new NumberData( 50 ) );
var avltree: AVLRoot = new AVLRoot( new NumberData( 50 ) );
for ( var i: Number = 0; i < 10; i++ )
{
var n: Number = random( 100 );
bintree.insert( new NumberData( n ) );
avltree.insert( new NumberData( n ) );
}
// because both trace methods sort the output automatically you wont see any difference
// but the find function of the avl would be much faster
trace( 'bintree' );
bintree.trace();
trace( 'avltree' );
avltree.trace();[/as]




0 Responses to “BinTree and AVLTree”