go to previous page   go to home page   go to next page hear noise highlighting

Answer:

number of pins in  2 rows =  2 + number of pins in 1 row = 

Recursion with Triangle Numbers

Here are the two parts to recursion:

  1. If the problem is easy, solve it immediately.
    • An easy problem is a base case.
  2. If the problem can't be solved immediately, divide it into smaller problems, then:
    • Solve the smaller problems by applying this procedure to each of them.

And here is how this applies to triangle numbers:

  1. Triangle( 1 ) = 1
  2. Triangle( N ) = N + Triangle( N-1 )

When N is larger than 1, the problem Triangle(N) is divided into two smaller problems:

Sometimes a smaller problem can be solved immediately (when it is the base case). Other times you need to continue breaking the problem into smaller problems.


QUESTION 6:

Using the above, what is Triangle(4)? Fill in the boxes starting with the second column of the top row and work your way down. When you hit the last row you can work your way up with the last two columns.

  Work Top to Bottom with this Column Work Bottom to Top with these Columns
Triangle( 4 ) = + Triangle( ) = + =
Triangle( 3 ) = + Triangle( ) = + =
Triangle( 2 ) = + Triangle( ) = + =
Triangle( 1 ) =    

go to previous page   go to home page   go to next page