Skip to content

Instantly share code, notes, and snippets.

@kartikkukreja
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kartikkukreja/d94541bce529a1d876d3 to your computer and use it in GitHub Desktop.
Save kartikkukreja/d94541bce529a1d876d3 to your computer and use it in GitHub Desktop.
Range update example node
struct SegmentTreeNode {
int start, end; // this node is responsible for the segment [start...end]
double total;
void assignLeaf(double value) {
total = value;
}
void merge(SegmentTreeNode& left, SegmentTreeNode& right) {
total = left.total + right.total;
}
double query() {
return total;
}
// the value of the update is dummy in this case
void applyUpdate(bool value) {
total = sqrt(total);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment