varinvertTree=function(root){if(root===null)returnnull;vartemp=root.left;root.left=invertTree(root.right);root.right=invertTree(temp);returnroot;};varinvertTree=function(root){if(root===null)return;//swapleftandrightchildvartemp=root.left;root.left=root.right;root.right=temp;//recurseintochildreninvertTree(root.left);invertTree(root.right);};這兩個程序的遞歸細節(jié)是一樣的嗎?
關(guān)于遞歸的理解?
一只萌萌小番薯
2019-04-21 20:14:42