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);};这两个程序的递归细节是一样的吗?
一只萌萌小番薯
森林海
随时随地看视频慕课网APP
相关分类