21
Carol Zander University of Washington, Bothell presents Recursion

Carol Zander University of Washington, Bothell presents Recursion

Embed Size (px)

DESCRIPTION

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 - PowerPoint PPT Presentation

Citation preview

Page 1: Carol Zander University of Washington, Bothell presents Recursion

Carol ZanderUniversity of Washington, Bothell

presents

Recursion

Page 2: Carol Zander University of Washington, Bothell presents Recursion

Background

• Virtues of active learningo Human Tableau (Angelo & Cross), students act

out key ideaso Kinesthetic Learning (Begel, Garcia, Wolfman),

physically engaging exercises o Active & Cooperative Learning (McConnell),

face-to-face interaction and group process

Page 3: Carol Zander University of Washington, Bothell presents Recursion

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

Page 4: Carol Zander University of Washington, Bothell presents Recursion

The set-up

Page 5: Carol Zander University of Washington, Bothell presents Recursion

Problem

• Evaluate a prefix expressiono valid expressiono single digit operandso operators: + - * /

• Worked with/ * + 9 3 – 4 2 + 5 1

which is (9+3)*(4-2)/(5+1)

Page 6: Carol Zander University of Washington, Bothell presents Recursion

Programint 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; }}

Page 7: Carol Zander University of Washington, Bothell presents Recursion

The execution

Page 8: Carol Zander University of Washington, Bothell presents Recursion

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

+

Page 9: Carol Zander University of Washington, Bothell presents Recursion

Run-time stack

• Idea was that they would form a human run-time stack

• Move around

• Pop off stack

• Push onto stack

Page 10: Carol Zander University of Washington, Bothell presents Recursion

The result

Page 11: Carol Zander University of Washington, Bothell presents Recursion

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

Page 12: Carol Zander University of Washington, Bothell presents Recursion

The following is a dramatization of the actual event. No students were actually clueless in the making of this presentation.

Page 13: Carol Zander University of Washington, Bothell presents Recursion
Page 14: Carol Zander University of Washington, Bothell presents Recursion
Page 15: Carol Zander University of Washington, Bothell presents Recursion
Page 16: Carol Zander University of Washington, Bothell presents Recursion

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

Page 17: Carol Zander University of Washington, Bothell presents Recursion

It seemed like agood ideaat the time

Page 18: Carol Zander University of Washington, Bothell presents Recursion

Lessons Learned

Page 19: Carol Zander University of Washington, Bothell presents Recursion

Not a complete failure

Besides learning to never try that active learning exercise ...

Page 20: Carol Zander University of Washington, Bothell presents Recursion

Recursion is very complex for students. They must fully understand problem-solving recursively first.

Executing recursive functions is so different from solving them ...

Page 21: Carol Zander University of Washington, Bothell presents Recursion

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