CS 241 Data Structures -- Spring 2013 -- Lab 1, Due 1/15 (by the end of lab)

Introduction

In single elimination tournaments, it is common to create the bracket so the strongest players cannot meet until the final round. The idea is that the best game will be the last; this is known as seeding. The best player (by some metric) is the number 1 seed, the second best, number 2, and etc.

Here are the initial pairings for an 8 player tournament:

the initial seeding is:

	1
	8
	5
	4
	3
	6
	7
	2
    
Notice that they are arranged so that if every favorite (the player with the higher seed is the favorite) wins, the round of 4 will be identical with an initial round of 4. I.e.
the initial seeding is:

	1
	4
	3
	2
    

Your task

Write a program which allows the user to enter a number that is a power of 2 in a JTextField (if it is not a number or a power of 2, complain, highlight the TextField, requestFocus, and let them enter again), and then prints the initial bracket for a tournament with that many players in a TextArea.

Your code should work for input values up to 28

Hint

Use recursion!

Details

  1. You may/should work with a partner -- but! both of you should understand how the code works!
  2. Demo your code during lab for credit.