#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Posts
    5
    Rep Power
    0

    Exclamation reversed binary tree


    i really need a class for a reversed binary tree!

    i want to do a tournament admin system with double out. which means there is

    a_
    _ a
    b


    a competes against b. if a wins then a is one more step to the root if b wins then ofcourse the other way round.
    i need to access every node and need to parse through the whole tree starting in the lowest branch and going up to the root!

    if anyone has a class or the algorithm please post here or post a link.

    thx - hope everyone understood what i need
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Posts
    20
    Rep Power
    0
    I suppose I don't really understand the problem.
    In a simple binary tree, copying the winner of a match to the parent (discard the children if you want) as can be seen in every display of tournaments should do the job:
    e.g
    x means empty

    quaterfinals
    x
    x x
    x x x x
    a b c d e f g h

    a wins against b
    d wins against c
    e wins against f
    g wins against h

    Semifinals
    x
    x x
    a d e g
    a b c d e f g h

    d wins against a
    e wins against g

    Finals
    x
    d e
    a d e g
    a b c d e f g h

    d wins against e
    d
    d e
    a d e g
    a b c d e f g h

    So a simple fully balanced binary tree with a depth first access should do the job!?!
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Posts
    5
    Rep Power
    0

    Thumbs up alright


    this would mean i would have to built the whole tree first!

    i dont want to do that since i put the data in a mysql table!

    but basically you are right - i just thought someone already has a class for that. i would actually need two binary trees because there is also a looser bracket (every team can loose once).

    thx, anyways

IMN logo majestic logo threadwatch logo seochat tools logo