CSC 216 F09/: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(3 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.


==State Machine Pass==


===The problem===
===Props===
1. Whiteboard


Trying to teach how finite state machines work.
2. Access to a Java editor


===Participants and props===
===Procedure===


Everybody in the class plays the game.  The only prop needed is a ball.  A diagram of the state machine is drawn on the board.
1) Give each row a sequence of numbers.  
The state machine will have two paths it can go down to reach the final state.
 
===The script===


The ball is thrown to a student in the class.  They will be at state 0.  They will be presented a condition to move to the next state.  If they answer right they toss the ball to another student.  If they get it wrong they keep the ball and take another turn.  This continues until the final state is reached. 
Ex:


===Acknowledgments===
a) 2, 6, 10, 14,...


Created by Josh Wilkerson and Tony McCarthy
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