Esempio n. 1
0
int main()
{
	list *ps;
	ps = create();
	ergodic(ps);
	ps = turn(ps);
	ergodic(ps);
	ps = turn(ps);
	printf("%d ", searchfive(ps));//输出的是反序后的节点
	printf("%d", searchsecondfive(ps));
	return 0;
}
Esempio n. 2
0
bool ergodic(vector<TreeNode*>& path, TreeNode* root, TreeNode* d)
{
    if (root == NULL) return false;
    if (root == d) {
        path.push_back(root);
        return true;
    }
    if (ergodic(path, root->left, d)) {
        path.push_back(root);
        return true;
    }
    if (ergodic(path, root->right, d)) {
         path.push_back(root);
         return true;
    }
    return false;
}
Esempio n. 3
0
vector<TreeNode*> pathToElem(TreeNode* root, TreeNode* d)
{
    vector<TreeNode*> path;
    ergodic(path, root, d);
    return path;
}