Print all nodes of the same level from binary tree

Discussion in 'C' started by budala, Sep 5, 2010.

  1. budala

    budala New Member

    Joined:
    Sep 5, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    This is the scenario:

    1. user inputs an int N for the desired level
    2. if N is greater than the total number of levels in the tree, repeat input
    3. if N is less than 0, repeat input
    4. if N is okay, print all the nodes belonging to this level.

    1-3 I know how to do, but 4 is a mystery :(

    I thought about putting all the nodes into an array, and then manually checking each of them if they are of the required level, but I'm not sure if that would take for ever :(
     
  2. go4expert

    go4expert Moderator

    Joined:
    Aug 3, 2004
    Messages:
    306
    Likes Received:
    9
    Trophy Points:
    0
    No it should not take forever
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice