The Frank Mich Binary Tree page shows that your tree entries will display as follows:
0 \ 1 / \ 2 \ \ 3 / \ 4 / \ \ / \ 5 \ / \ 6 \ \ 7 / 8 / \ / 9 / / \ / 10 \ / \ / 11 / 12 / \ / 13 / 14
Where each number in the tree represents the index of its entry in the input array. Note that counting the column of the first round, the indices grow by 2. In the second column they rise by 4, and in the third column by 8.
I would create an array of strings with the name of each game in them. Then do something like this:
num_rounds = x num_games = (2 ^ num_rounds) - 1 game_names = array(num_games) for round = 0 to num_rounds - 1 index = (2 ^ round) - 1 increment = 2 ^ (round + 1) game_number = 0 while index < num_games game_names[index] = sprintf("round %s, game %s", round, game_number) game_number++ index += increment display_tree(game_names)
source share