/*
public class TreeLinkNode {
int val;
TreeLinkNode left = null;
TreeLinkNode right = null;
TreeLinkNode next = null;
TreeLinkNode(int val) {
this.val = val;
}
}
*/
public class Solution {
public TreeLinkNode GetNext(TreeLinkNode pNode){
if(pNode.right!=null){
pNode=pNode.right;
while(pNode.left!=null){
pNode=pNode.left;
}
return pNode;
}
else{
while(pNode.next!=null){
TreeLinkNode parentNode=pNode.next;
if(parentNode.left==pNode)
return parentNode;
else{
pNode=pNode.next;
}
}
return null;//这儿错了 之前写的pNode
}
}
}
算法没想到,这种有无右节点的分类方法需要记住