2014年3月2日

Lowest Common Ancestor of a Binary Tree & Binary Search Tree

摘要: 这里有两种情况,一种是Binary Tree,一种是Binary Search Tree。Binary Search Tree1 Node *LCA(Node *root, Node *p, Node *q) {2 if (!root || !p || !q) return NULL;3 if (max(p->data, q->data) data)4 return LCA(root->left, p, q);5 else if (min(p->data, q->data) > root->data)6 return LCA(root->righ 阅读全文

posted @ 2014-03-02 12:28 longhorn 阅读(213) 评论(0) 推荐(0) 编辑

导航