标签:tmp node val div == 插入 ast tree pre
TreeNode insertNode(TreeNode root,TreeNode node){ if(root == node){ return node; } TreeNode tmp = new TreeNode(); tmp = root; TreeNode last = null; while(tmp!=null){ last = tmp; if(tmp.val>node.val){ tmp = tmp.left; }else{ tmp = tmp.right; } } if(last!=null){ if(last.val>node.val){ last.left = node; }else{ last.right = node; } } return root; }
标签:tmp node val div == 插入 ast tree pre
原文地址:https://www.cnblogs.com/yingpu/p/9287210.html