Home Segments Index Top Previous Next

310: Practice

The number of positions at the bottom of a game tree with depth d and b choices at each position is bd. The total number of positions in that game tree is 1+b+b2++bd. Write an iterative method, using the timesRepeat: message, to be sent to a number representing b with an argument representing d, that computes the total number of positions. Use your program to compute the total number of positions in a game tree with b=2 and d=10. Repeat with b=15 and d=100.