摘要:
LCA 分为几种情况1. Binary Search Tree 的 LCA2. Binary Tree with parent pointer3. Binary Tree without parent pointer4. ordinary Tree without parent pointerBinary Search Tree思路1. 对一个节点 node, 假如 n1,n2 均大/小于 node->val, 那么LCA一定在 node->right 分支上2. 若一个大于一个小于, 则 LCA 就是 node 本身3. updown 解法, log(n) 的时间复杂度Binar 阅读全文
posted @ 2014-01-17 21:25
SangS
阅读(596)
评论(0)
推荐(0)
摘要:
在做 compiler 语义分析时, 需要用到 map在别人的代码上做扩展, 所以有些代码是不能动的这时, 需要一个 map 的数据结构, 但是我并不清楚 symbol 是否重载了 , 成功了#include #include using namespace std;class unknow {private: int index;public: int get_index() { return index; } void increment() { index++; } /* bool operatorindex mapping; unknow *u1 = new unknow(); ... 阅读全文
posted @ 2014-01-17 20:17
SangS
阅读(1172)
评论(0)
推荐(0)

浙公网安备 33010602011771号