Last active
August 29, 2015 14:09
-
-
Save kartikkukreja/fd12908dcb562e8826a1 to your computer and use it in GitHub Desktop.
Segment tree node
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct SegmentTreeNode { | |
// variables to store aggregate statistics and | |
// any other information required to merge these | |
// aggregate statistics to form parent nodes | |
void assignLeaf(T value) { | |
// T is the type of input array element | |
// Given the value of an input array element, | |
// build aggregate statistics for this leaf node | |
} | |
void merge(SegmentTreeNode& left, SegmentTreeNode& right) { | |
// merge the aggregate statistics of left and right | |
// children to form the aggregate statistics of | |
// their parent node | |
} | |
V getValue() { | |
// V is the type of the required aggregate statistic | |
// return the value of required aggregate statistic | |
// associated with this node | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment