Look through the sequence of building matrices:

Let us build a table indicating how many matches are need to build each set of squares:

Number of matchsticks | |
---|---|

Fill in the missing values. Click outside the box once you have entered each value to check the correctness of your entry.

If you watch carefully you will be able to see that each time we add a new layer of boxes to make a * n x n* matrix , we add

Thus we can conclude that if it takes ** p** matchsticks to form a matrix of

matchsticks = 0 for i = 1 to n matchsticks = matchsticks + 4 x i

**Alternatively** we can compute the number of matchsticks needed for boxes of size greater than ** 4** by constructing a difference table, and noting that the second difference is a constant

Squares | Number of Matchsticks | 1st Difference | 2nd Difference |
---|---|---|---|

Complete this table, so that you can compute the number of matchsticks needed to complete a ** 7 x 7** matrix.

**Yet again** we can find a different means to compute the number of matchsticks in ** (n x n)** matrices. Note that in each row of a

**ALTERNATIVE SOLUTIONS** to problems are important to us for several reasons.

- They provide an opportunity to choose the best algorithm for computation, whether the choice is to be based on speed or space.
- They provide a means of double checking the results of our computations by checking the results of one algorithm against those of another.

Our implementation of algorithms, unfortunately, are not always correct. However by using an alternative solution enables us to check the results and to know when the results are questionable. It is better to give the answer of "I don't know" than to give a wrong answer!

Last updated 2001/02/27

© J.A.N. Lee, 2001.