假设我们有以下树:
1
9
2
13
3
10
4
15
5
11
6
14
7
12
8
其中元素(匹配):
1-8 是第 1 轮
9-12 是第 2 轮
13-14 是第 3 轮
15 是第 4 轮
如何确定树中元素“n”的轮次?
我目前的公式是:
total_rounds = floor(log(totalTeams,2));
matches_per_round = (totalTeams / pow(2, current_round))
next_match_id = (totalTeams/2) + ceil(match_id/2)
total_matches = total_teams - 1