#!/usr/bin/perl /usr/bin/asp-perl <% my $count; my $winner = { value => 'wwabwcd', left => { value => 'wab', left => { value => 'a'}, right => { value => 'b'}}, right => { value => 'wcd', left => { value => 'c', left => { value => 'X'}}, right => { value => 'd'}}}; my $loser = { value => 'second', left => { value => 'wlablcd', left => { value => 'lab'}, right => { value => 'lcd'}}, right => { value => 'lwabwcd'}}; my $brock = { value => 'Me', left => { value => 'Russle Brock Wilcox Sr', left => { value => "Russle Eugene Wilcox"}, right => { value => "Letha Wilcox"}}, right => { value => 'Kandy Kay Rosson', left => { value => 'Joseph Rosson'}, right => { value => 'Kay Rosson'}}}; $childnum = 0; sub build_tree { my ($depth) = @_; if($depth == 0) { return {value => $childnum++}; } return { left => build_tree($depth - 1), right => build_tree($depth - 1), value => $childnum++}; } my $hrm = build_tree(4); sub tree_depth { my ($node) = @_; my $depth = 0; if($node->{left}) { $depth = tree_depth($node->{left}); } if($node->{right}) { my $right_depth = tree_depth($node->{right}); $depth = $right_depth if ($right_depth > $depth); } return 1 + $depth; } sub draw_tree { my ($node, $depth, $tree_depth, $side, @lines) = @_; my $child_depth = $tree_depth - $depth; if($node->{left}) { my @left_lines = @lines; if($side eq 'right') { push @left_lines, $depth; } draw_tree($node->{left}, $depth+1, $tree_depth, 'left', @left_lines); } print "
|
|