MCPcopy Create free account
hub / github.com/acm-clan/algorithm-stone / updateNode

Method updateNode

templates/segment-tree.cpp:49–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47 }
48
49 void updateNode(TreeNode * n, int pos, int val){
50 if(!n)return;
51
52 if(n->l == n->r && n->l == pos){
53 n->v = val;
54 return;
55 }
56
57 int m = (n->l+n->r)/2;
58
59 // 后序遍历
60 if(pos <= m){
61 updateNode(n->left, pos, val);
62 }else{
63 updateNode(n->right, pos, val);
64 }
65 n->v = n->left->v + n->right->v;
66 }
67
68 int query(TreeNode * n, int l, int r){
69 if(!n)return 0;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected