CSC 216 F09/: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
(5 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
==Background== | |||
This is a simple exercise for finding recursive equations and writing them as Java code. | |||
===Props=== | |||
1. Whiteboard | |||
2. Access to a Java editor | |||
===Procedure=== | |||
1) Give each row a sequence of numbers. | |||
Ex: | |||
a) 2, 6, 10, 14,... | |||
b) 0, 1, 0, 1... | |||
c) 2, 6, 12, 20... | |||
d) 1, 4, 9, 16... | |||
2) Then have each row work together to find the recursive definition for the sequences. | |||
Ex: | |||
a) 4n-2 | |||
b) 1+(-1)^n | |||
c) n(n + 1) | |||
d) n^2 | |||
3) Lastly, each group should write Java code to implement the recursive equation and submit via Google Docs. | |||
Ex: | |||
a) | |||
public int recursion( int n ){ | |||
int a = 0; | |||
if(n == 1) a = 2; | |||
else a = recursion( n - 1 ) + 4; | |||
return a; | |||
} | |||
By: David Duran & Dereck Allred |
Latest revision as of 02:51, 18 November 2009
Background
This is a simple exercise for finding recursive equations and writing them as Java code.
Props
1. Whiteboard
2. Access to a Java editor
Procedure
1) Give each row a sequence of numbers.
Ex:
a) 2, 6, 10, 14,...
b) 0, 1, 0, 1...
c) 2, 6, 12, 20...
d) 1, 4, 9, 16...
2) Then have each row work together to find the recursive definition for the sequences.
Ex:
a) 4n-2
b) 1+(-1)^n
c) n(n + 1)
d) n^2
3) Lastly, each group should write Java code to implement the recursive equation and submit via Google Docs.
Ex:
a)
public int recursion( int n ){
int a = 0; if(n == 1) a = 2; else a = recursion( n - 1 ) + 4; return a;
}
By: David Duran & Dereck Allred