GeeksforGeeks » Algorithms

BFS ( INSERTION )

(1 post)
  • Started 8 months ago by jammy

Tags:

  1. jammy
    guest
    Posted 8 months ago #

    Hi,
    i looked at the source code and understand it very well located on

    http://geeksforgeeks.org/?p=2686

    how can i insert the new nodes in the tree with such tree logic?

    A

    when A refers B, then B will go on A's level 1 since it's empty like this:

    A
    B

    Now if A refers C, then the matrix will look like this:
    A
    B C

    Now if A refers D, then D will go under B like this:

    A
    B C
    D
    Now if A also refers E, then E will go under C:

    A
    B C
    D E
    Now if A refers F, then F will go under B:
    A
    B C
    D F E
    If A refers G, then G will go under C:

    A
    B C
    D F E G

    I badly need your help, please do answer me :-(


Reply

You must log in to post.

RSS feed for this topic