Notes On Blockus

Part 1

Review Recursion int fib(nit n) {

 If (n==0) return 0;
 If(n==1) return 1;
 Return fin(n-1)+fib(n-2);

}

How many ways can you split 3 into different ways? 3 1 2 2 1 1 1 1

For any number n be about to generate all the possible types.

. = uncertain numbers

4 2 . . (two possible numbers to pick 1 or 2) 1. (one possible number left the pick 1) 1

Think of it as a budget Can always spend 1 to n USE A FOR LOOP

For nit partition of 7 4 … 1.. 2. 1.



//BUDGET COUNT IDEAS

void int p (int n) {

 int p;
 if(n <= 0) return;
 for (i = 1; i <= n; i++)

{

 int p( n -i);

}



void int p2 (int [] pout, int curr, int n) {

 int i;
 if(n ==0)
 {
   for(i = 0; i < curr; i++)
   {
     printf("%d", pout[1]
   }
 printf("\n")l
 return;
 }
 for (i = 0; i <= n; i++) {
   pout [curr] = n -1;
   int p2 (pout, curr +1, i);
 }

}



Back to ECE264

Alumni Liaison

Ph.D. 2007, working on developing cool imaging technologies for digital cameras, camera phones, and video surveillance cameras.

Buyue Zhang