3 ms·
I don't know JavaScript (maybe it somehow handles this automagically) but isn't his reverse function missing the base case of a NULL tree? function reverse(t
by gone35 11y ago
I don't know JavaScript (maybe it somehow handles this automagically) but isn't his reverse function missing the base case of a NULL tree?
function reverse(t) {
var tmp = t.left;
t.left = reverse(t.right);
t.right = reverse(tmp);
return t;
}
- tomjohnson3 11y agoyep - this would throw an exception. ...and it's missing other things too. ;-)