210 likes | 325 Vues
Carol Zander University of Washington, Bothell presents Recursion. Background. Virtues of active learning Human Tableau (Angelo & Cross), students act out key ideas Kinesthetic Learning (Begel, Garcia, Wolfman), physically engaging exercises
E N D
Carol Zander University of Washington, Bothell presents Recursion
Background • Virtues of active learning • Human Tableau (Angelo & Cross), students act out key ideas • Kinesthetic Learning (Begel, Garcia, Wolfman), physically engaging exercises • Active & Cooperative Learning (McConnell), face-to-face interaction and group process
Background • Colleague was teaching recursion in a CS2-like course • Allowed me to present a problem, solve it, and have the students simulate the run-time stack
Problem • Evaluate a prefix expression • valid expression • single digit operands • operators: + - * / • Worked with / * + 9 3 – 4 2 + 5 1 which is (9+3)*(4-2)/(5+1)
Program int evaluate(index in array) { char symbol = expr[++index]; if (symbol is a an operand) return symbol as a digit; // symbol is an operator + int leftOperand = evaluate(index); int rightOperand = evaluate(index); switch (symbol) { case ‘+’: return leftOperand + rightOperand; case ‘-’: return leftOperand – rightOperand; case ‘*’: return leftOperand * rightOperand; case ‘/’: return leftOperand / rightOperand; default: break; } }
Run-time stack Each student got an index card with one symbol from the prefix expression on it They were to use the board for the rest of the memory of the activation record 3 +
Run-time stack • Idea was that they would form a human run-time stack • Move around • Pop off stack • Push onto stack
Anticipated an ah-ha moment . . . Instead it was an uh-oh moment Actual results were absolute, glorious, complete cluelessness! They had no idea what was going on
The following is a dramatization of the actual event. No students were actually clueless in the making of this presentation.
Not a complete failure Besides learning to never try that active learning exercise ...
Recursion is very complex for students. They must fully understand problem-solving recursively first. Executing recursive functions is so different from solving them ...
Is it a chicken-and-egg problem? Perhaps a simple, linear recursive problem in class ... Give the prefix problem for homework. Have them draw an execution tree. Good idea??