美文网首页
Morris Traversal(前序)

Morris Traversal(前序)

作者: codingcyx | 来源:发表于2018-04-13 22:29 被阅读0次
    捕获.PNG
    void flatten(TreeNode* root) {
            if(!root) return ;
            TreeNode* cur = root;
            TreeNode* pre = NULL;
            while(cur){
                if(cur -> left){
                    pre = cur -> left;
                    while(pre -> right)
                        pre = pre -> right;
                    pre -> right = cur -> right;
                    cur -> right = cur -> left;
                    cur -> left = NULL;
                }
                cur = cur -> right;
            }
        }
    

    解释:


    捕获.PNG

    相关文章

      网友评论

          本文标题:Morris Traversal(前序)

          本文链接:https://www.haomeiwen.com/subject/vznhkftx.html