//This is what we are asked to print in the assignment of Binary Search Trees.The Nodes are printed like:

 F
     +-- D
     |    +-- NULL
     |    \-- NULL
     \-- R
          +-- P
          |    +-- M
          |    |    +-- NULL
          |    |    \-- N
          |    |         +-- NULL
          |    |         \-- NULL
          |    \-- NULL
          \-- V
               +-- NULL
               \-- NULL


/*But I am not  able to print "|".
Please help.
I have printed the bst like:*/

 F
     +-- D
            +-- NULL
             \-- NULL
     \-- R
          +-- P
             +-- M
               +-- NULL
               \-- N
                       +-- NULL
                    \ -- NULL
             \-- NULL
          \-- V
               +-- NULL
               \-- NULL

Why not? Just print '|'.

#include <iostream>
using namespace std;

int main()
{
    cout << "||||||||||" << endl;
    
    return 0;
}

Edited 6 Years Ago by WaltP: n/a

Why not? Just print '|'.

#include <iostream>
using namespace std;

int main()
{
    cout << "||||||||||" << endl;
    
    return 0;
}

I have to print the "|" between the left node and right node of a binary search tree.

/*This is the assignment statement.
For BST insertion, if the input contains the following

    F
    D
    R
    P
    V
    M
    N
The resulting BST should be displayed as:
    F
     +-- D
     |    +-- NULL
     |    \-- NULL
     \-- R
          +-- P
          |    +-- M
          |    |    +-- NULL
          |    |    \-- N
          |    |         +-- NULL
          |    |         \-- NULL
          |    \-- NULL
          \-- V
               +-- NULL
               \-- NULL
*/
This article has been dead for over six months. Start a new discussion instead.