Jump to content

Making a playoff tree


mikeg542

Recommended Posts

Hi, just a logic question:

 

We have a DB that has a table for matches with the relevant fields being: id, team1, team2, nextplayoffid, playoffround.

The user is supposed to be able to enter a team id and have it return the playoff tree.

The system was made so that ALL byes are done in the first round, so for example, a 5 person playoff would have 3 first round byes and 1 game, then 2 games then 1. Bye rounds are NOT in the DB.

 

 

For example here would be the DB

id            team 1                  team 2            nextplayoffid    playoffround

1                  15                      16                        2                    1

2                  14                        -                        4                    2

3                  17                      18                        4                    2

4                  -                        -                        -                    3

 

And this should display:

 

15

vs --------

16          |winner

              --vs---

14          |  14    |

vs---------        |

bye                    | winner

                          --vs----

17                    |  winner

vs---------        |

bye          |  17  |

                --vs---

18            |  18

vs --------

bye

 

 

The playoffs can be between 4 and 11 teams.

The number of games/byes first round is:

4 2 games/0bye

5 1 game/3byes

6 2 games/2byes

7 3 games/1bye

8 4 games/0byes

9 1 game/7byes

10 2 games/6 byes

11 3 games/5byes

 

 

I just would like to hear the best logic way of doing this.

My idea was to use a recursive function like function (node, left, right), but I don't know how to get that to do both the left AND right node simultaneously instead of sequentially (which obviouslly creates problems if done sequentially)

 

Any help would be appreicated!

Link to comment
https://forums.phpfreaks.com/topic/148647-making-a-playoff-tree/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.