Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Dumping trees to a console.

by BrowserUk (Pope)
on Oct 15, 2012 at 14:11 UTC ( #999091=CUFP: print w/replies, xml ) Need Help??

Dumping trees to a terminal in a compact, readable form is an invaluable aid to developing and debugging tree-based algorithms. The following demonstrates a mechanism for doing this for array-based binary trees:

A couple of examples:

C:\test>genBinTree -S=1 ___________ ___________/ \___ _______/ \_ _/ \ _____/ \_ _/ \_ _/ \_ z _/ \_ _/ \_ _/ \ / \ _/ \ / \ _/ \_ _/ \ _/ \ / \ _/ \ r s t / \ w x y _/ \ / \ / \ h / \ k m n / \ q u v / \ c d e f g i j o p a b C:\test>genBinTree -S=1 -N ___________ ___________/ \___ _______/ \_ _/ \ _____/ \_ _/ \_ _/ \_ z _/ \_ _/ \_ _/ \ / \ _/ \ / \ _/ \_ _/ \ _/ \ / \ _/ \ r s t / \ w x y _/ \ / \ / \ h / \ k m n / \ q u v / \ c d e f g i j o p a b a b c d e f g h i j k m n o p q r s t u v w x y z l r h e c o o o n u i i o s a u o i a n i h r a u p a a l h x l t d l l k v c p e m e n i c i a n l h v r t o t f e i i o e e a a b e r g f t s y k u a o l a r l g e m r e o r o o o k e i o o t b c a r r e e e t e m y r C:\test>genBinTree -S=1234567890123456789 _____________________ _______/ \_ _______/ \___________ _/ \___ _/ \ _____/ \ _/ \ / \_ / \___ f / \_________ q _/ \ v w _/ \ a / \_ g ___/ \ _/ \ u / \ z b _/ \ / \_____ p / \ t x y / \ e h _/ \_ r s c d / \_ _/ \ i / \ / \ o j k m n C:\test>genBinTree -S=123456789012345678 _______ ___/ \_ _/ \_ _/ \_______ / \_ / \_ / \ / \_________ a / \ d / \ g h i _/ \___________ b c e f _/ \ ___/ \_ _/ \ n _/ \ _____/ \ / \ m _/ \_ s ___/ \ z j k / \ / \ / \_ y o p q r t _/ \_ / \ / \ u v w x

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

RIP Neil Armstrong

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: CUFP [id://999091]
Approved by Corion
help
Chatterbox?
[jdporter]: Dang. No good example of how to use IPC::Run's run() in its simplest mode?
[LanX]: him or her! ;)
[1nickt]: jdporter Maybe try IPC::Run3
[LanX]: Sandy Koufax is indeed rude. .. oO
[chacham]: Re: Re: pattern matching -- feeling stoopit a poll idea about centrists, is +8 -5, used to be +6/-6 how apropos :)is +8
[chacham]: ...errr... Re: poll ideas quest 2015 (political centrist)
[chacham]: ooh, late, nighty nite everybody

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (15)
As of 2017-05-24 20:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?