A binary tree isthreadedby making all right child pointers that would normally be null point to the inorder successor of the node (ifit exists), and all left child pointers that would normally be null point to the inorder predecessor of the node. 就是说线索二叉树实际上是把所有原本为空的...
线索二叉树介绍 首先我们引入“线索二叉树”的概念: "A binary tree isthreadedby making all right child pointers that would normally be null point to the inorder successor of the node, and all left child pointers that would normally be null point to the inorder predecessor of the node." 线索...
Solution2_a Code:Find Inorder Predecessor publicTreeNodepredecessor(TreeNode root,TreeNode p){if(root==null)returnnull;if(root.val>=p.val){returnpredecessor(root.left,p);}else{TreeNode right=predecessor(root.right,p);return(right!=null)?right:root;}} Solution2_b Code:Find Inorder Success...
A binary tree isthreadedby making all right child pointers that would normally be null point to the inorder successor of the node (ifit exists), and all left child pointers that would normally be null point to the inorder predecessor of the node. ...