Binary tree display?

This is a discussion on Binary tree display? within the C++ Programming forums, part of the General Programming Boards category; I just completed the binary tree tutorial in cprogramming.com... like you can display a linked list like so: 12 => ...

  1. #1
    Registered User
    Join Date
    Jul 2012
    Posts
    36

    Binary tree display?

    I just completed the binary tree tutorial in cprogramming.com...

    like you can display a linked list like so:

    12 => 412 => 45123 => 99 => NULL...

    or something like that..

    how can we display a b.tree using a display() function or something...

    (i wanna display it like so: if possible):
    Code:
    /*
                                                       12
                                                     /     \
                                                   9       15
                                                 /   \    
                                               3      12
    */

  2. #2
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Posts
    2,599
    Not impossible, but I'd suggest a more display friendly format.
    Code:
    12
        L
        9
            L
            3
            R
            12
        R
        15
    That would show the whole thing clearly and would be much simpler to code.

    Disregard if the displaying is for ornamental purposes and not for debugging.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Converting From Binary Tree to Threaded Binary Trees
    By elton_fan in forum C Programming
    Replies: 15
    Last Post: 11-08-2007, 10:41 PM
  2. Replies: 2
    Last Post: 08-01-2007, 01:08 PM
  3. Replies: 0
    Last Post: 11-04-2006, 10:07 AM
  4. Binary tree display
    By logicwonder in forum C Programming
    Replies: 2
    Last Post: 04-02-2006, 12:14 AM
  5. display tree data in binary tree format
    By xddxogm3 in forum C++ Programming
    Replies: 4
    Last Post: 12-10-2003, 11:47 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21