找出二叉树中序遍历的所求节点的下一个节点
2012-09-07 21:32
211 查看
typedef struct node { int data; struct node* left; struct node* right; struct node* parent; }NODE; NODE *findSuccessorInorder(NODE* node) { NODE *pNode = node; if (pNode->right != NULL) { pNode = pNode->right; while (pNode->left != NULL) { pNode = pNode->left; } return pNode; } else if (pNode->parent) { NODE *pParent = pNode->parent; while (pParent && pParent->right == pNode) { pNode = pParent; pParent = pNode->parent; } return pParent; } else { return NULL; } }
相关文章推荐
- 4.6 找出二叉树中指定节点的下一个节点(中序后继),假定每个节点有父指针。
- 二叉树中序遍历的下一个节点
- 找出二叉树中指定结点的下一个结点(中序后继)可以假定每个结点都有指向父节点的连接
- 剑指offer:找到二叉树中序遍历的下一个节点
- 树——二叉树中序遍历的下一个节点
- 二叉树中序遍历的下一个节点
- 找出BST上任意节点的下一个节点
- 二叉树的下一个节点
- LeetCode OJ:Populating Next Right Pointers in Each Node II(指出每一个节点的下一个右侧节点II)
- 剑指Offer面试题58:二叉树的下一个节点
- 返回中序遍历的一个节点的下一个节点
- 二叉树的下一个节点
- LeetCode算法题集-513. Find Bottom Left Tree Value(找出左下角的叶子节点)
- 寻找下一个节点
- 二叉树的下一个节点
- 找出有环链表中环的起始节点
- 剑指offer系列之56:二叉树的下一个节点
- 【二叉树】二叉树的下一个节点
- JavaScript实现在textbox输入时自动去数据库匹配并找出类似值列出,选择后记得将值填入本textbox及下一个textbox
- 左孩子右兄弟表示多叉树查找返回下一个节点