3 ms·
I agree you should start with the data structure. Give someone a recursive data structure and have them try to write a function that does stuff with it.
by klysm 4y ago
I agree you should start with the data structure. Give someone a recursive data structure and have them try to write a function that does stuff with it.
- tralarpa 4y agoYes, a binary tree and a simple function, like calculating the sum of all node values. That's a no-brainer. The funny thing is that when you present it the students first find it obvious (e.g. "sum = value of node + sum of left child + sum of right child, yes, easy, makes sense"), but then they start to think about it and then comes the "wait, why does that work???" phase, and it turns out they had not understand how procedure calls, arguments, and local variables really work up to that point.