Professional Documents
Culture Documents
Selected Exercises
Exercise 30
Devise a recursive algorithm to find the nth term of
the sequence defined by:
a0 = 1, a1 = 2
an = an-1 an-2, for n = 2, 3, 4,
int a( int n )
{
assert n >= 0;
return ( n <= 1) ? n + 1 : a( n - 1) * a( n - 2 );
}
010 011
100 101
000 001
A path that visits each vertex exactly once is Hamiltonian.
There is a 1-to-1 correspondence between Hamiltonian paths
in the n-cube and n-bit gray codes.
Copyright Peter Cappello 13
Gray Codes & the N-Cube
000
001
110 111
011
010 011 111
101
100 101
100
000 001
110
010
Copyright Peter Cappello 14
RGB Colors
No:
All:
0 0 0 0 0 0
1 0 1 0 0 1
1 1 0 1 1
1 0 0 1 0
1 1 0
1 1 1
1 0 1
1 0 0
16 15 14 13 16
9 10 11 12
8 7 6 5
1
1 2 3 4
Copyright Peter Cappello 25