public class Tree1 { public static void main(String[] args) { int height = 3; int nodes = (int) (Math.pow(2,height)-1); Person[] ps = new Person[nodes]; // Array of people: for (int i = 0; i < nodes-1; i++) ps[i]=new Person("p"+i); // Build tree of people: /* 0 p / \ / \ 1 2 m f / \ / \ 3 4 5 6 */ ps[0].mother = ps[1]; ps[0].mother = ps[2]; ps[1].mother = ps[3]; ps[1].mother = ps[4]; ps[2].mother = ps[5]; ps[2].mother = ps[6]; // count people....? } } class Person { public String name; public Person father; public Person mother; public Person(String name) {this.name=name;} public String toString() {return name;} }