# Carol Zander University of Washington, Bothell presents Recursion.

## Presentation on theme: "Carol Zander University of Washington, Bothell presents Recursion."— Presentation transcript:

Carol Zander University of Washington, Bothell presents Recursion

Background Virtues of active learning o Human Tableau (Angelo & Cross), students act out key ideas o Kinesthetic Learning (Begel, Garcia, Wolfman), physically engaging exercises o 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

The set-up

Problem Evaluate a prefix expression o valid expression o single digit operands o 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; }

The execution

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

The result

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.

Such a shame that it was such a dismal failure because...

It seemed like a good idea at the time

Lessons Learned

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??