How to display data in a bst in tree format using C++?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • techie929
    New Member
    • Feb 2010
    • 1

    How to display data in a bst in tree format using C++?

    I have to display nodes in bst in the below given format:

    I have insesrted the nodes properly and able to display it using preorder.

    if the nodes are F,D,E...the output should come as:

    Code:
    F
     + - - D
              + - - NULL
              \ - - E
                      + - - NULL
                       \ - - NULL
     \ - - NULL
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    Probably your display function needs to be recursive. As it walks the tree itIt should call itself when the next pointer is not NULL.

    Comment

    Working...