Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Tree Data Structure

by code-ninja (Scribe)
on Dec 04, 2013 at 07:19 UTC ( [id://1065546]=note: print w/replies, xml ) Need Help??


in reply to Tree Data Structure

Taking kcott and Laurent_R's suggestions, I changed my traverse function to look like this:

sub traverse { my $tree = shift; return unless defined $$tree->{left} and defined $$tree->{right}; traverse(\$tree->{left}); print $$tree->{val}; print "\n"; traverse(\$tree->{right}); }

The code runs fine, but there is no output. I guess I made a very basic mistake in the insert function but I can't figure it out. Can someone point me to an implementation of binary tree in Perl? I do not intend to use the Tree::Binary module.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1065546]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-04-25 04:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found