标签:interview
// BST. class Node { Node parent; Node left; Node right; } Node min(Node node) { if (node == null) return null; while(node.left != null) node = node.left; return node; } // in-order ? Node next(Node node) { if (node == null) return null; if (node.right != null) { Node toReturn = node.right; while (toReturn.left != null) { toReturn = toReturn.left; } return toReturn; } while( node != null) { if (node == node.parent.left) return node.parent; else node = node.parent; } return null; }
标签:interview
原文地址:http://7371901.blog.51cto.com/7361901/1583044