Results 1 to 5 of 5

Thread: [RESOLVED] Tree Traversal

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2007
    Posts
    912

    Resolved [RESOLVED] Tree Traversal

    hi all,
    i have a problem, please help me out to solve this issue,

    i have to traverse a Tree from Given Root and i have to count its Left Childs And Its Right Childs.

    I have a database which stores this all information.

    A Root can have only TWO Childrens.

    Please tell me how can i count ROOT(S), Left And Right Childs

    In table im saving all this like this

    Field Name : Assigned_Left_To (Left Child ID)
    Field Name : Assigned_Right_To (Right Child ID)

    please solve my problem and give me a function to solve this problem

  2. #2
    Frenzied Member the182guy's Avatar
    Join Date
    Nov 2005
    Location
    Cheshire, UK
    Posts
    1,473

    Re: Tree Traversal

    Hi chunk,

    I don't understand exactly what you are looking for, your going to have to be much more specific if you want anybody to solve your problem.

    Quote Originally Posted by chunk
    i have to traverse a Tree from Given Root and i have to count its Left Childs And Its Right Childs.
    What do you mean by a given root? Do you mean a record in the database table called root?

    Quote Originally Posted by chunk
    I have a database which stores this all information.
    You're going to need to tell us the table structure for all tables that are relevant.

    Quote Originally Posted by chunk
    A Root can have only TWO Childrens.

    Please tell me how can i count ROOT(S), Left And Right Childs
    If a root can only have 2 children then why do you need to count them, according to that there will always be 2.

    Quote Originally Posted by chunk
    In table im saving all this like this

    Field Name : Assigned_Left_To (Left Child ID)
    Field Name : Assigned_Right_To (Right Child ID)
    What is this? Table structure for the 'root' table? If so, can't you just check if Left is 0 and if Right is 0, that will tell you there is 0 children, if Left and Right have a value then you have 2 children.

    Quote Originally Posted by chunk
    please solve my problem and give me a function to solve this problem
    A function? Are you looking to create a fuction, if so what are the inputs, what are the outputs and what exactly is the purpose? Or are you referring to built in functions such as the COUNT() function of SQL?
    Chris

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2007
    Posts
    912

    Re: Tree Traversal

    thanks for repling me the182guy

    you are right i should have been explain my problem in good manner and with good explanation.

    i have found the solution of it, and it is now working fine for me.

    if in future i need any help regarding this topic. i will continue this thread. or i will start a new one.


    thank you so much for repling me bro

  4. #4
    Frenzied Member the182guy's Avatar
    Join Date
    Nov 2005
    Location
    Cheshire, UK
    Posts
    1,473

    Re: [RESOLVED] Tree Traversal

    No problem chunk, glad you sorted it out
    Chris

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2007
    Posts
    912

    Re: [RESOLVED] Tree Traversal

    thanks again for your reply bro

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width