Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Comment on

( #3333=superdoc: 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


In reply to Dumping trees to a console. by BrowserUk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others drinking their drinks and smoking their pipes about the Monastery: (12)
    As of 2014-08-01 15:53 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      Who would be the most fun to work for?















      Results (28 votes), past polls