Thread: Binary tree display

  1. #1
    Logic Programmer logicwonder's Avatar
    Join Date
    Nov 2005
    Kerala, India

    Question Binary tree display

    How can I display a binary tree showing its real structure like.
    Can any one suggest an algorithm for this purpose

                               3                  8
                          1        4        6        9
    L GIK wins!!!
    Salutes from logicwonder
    Enjoy programming

  2. #2
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003
    Check out a Breadth First Algorithm

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    First thing you probably need is something to work out the height of the tree, in order to work out how far to indent the root node.

    Then something to take that base level indentation, and with each L or R move, subtract or add an appropriate level of indentation based on the current depth of the traversal.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple binary search tree?
    By sybariticak47 in forum C++ Programming
    Replies: 8
    Last Post: 08-09-2007, 03:53 PM
  2. please help with binary tree, urgent.
    By slickestting in forum C Programming
    Replies: 2
    Last Post: 07-22-2007, 07:55 PM
  3. best STL method to implement a binary tree
    By MatthewDoucette in forum C++ Programming
    Replies: 8
    Last Post: 06-16-2006, 07:08 AM
  4. Request for comments
    By Prelude in forum A Brief History of
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  5. display tree data in binary tree format
    By xddxogm3 in forum C++ Programming
    Replies: 4
    Last Post: 12-11-2003, 12:47 AM