标签:dll public logs idt double null 分享 bin linked
public TreeNode binaryTree2List(TreeNode node) { if (node == null) return node; // Convert to DLL using bintree2listUtil() node = bintree2listUtil(node); while (node.left!=null) { node=node.left; } return node; } TreeNode bintree2listUtil(TreeNode node) { if (node==null) { return node; } if (node.left!=null) { TreeNode leftNode=bintree2listUtil(node.left); while (leftNode.right!=null) { leftNode=leftNode.right; } leftNode.right=node; node.left=leftNode; } if (node.right!=null) { TreeNode rightNode=bintree2listUtil(node.right); while (rightNode.left!=null) { rightNode=rightNode.left; } rightNode.left=node; node.right=rightNode; } return node; }
Convert a given binary tree to double linked list
标签:dll public logs idt double null 分享 bin linked
原文地址:http://www.cnblogs.com/lilyfindjobs/p/7500110.html