Created
July 1, 2019 16:54
-
-
Save manosriram/9a7616d9f091c447300fdc6d94d3739b to your computer and use it in GitHub Desktop.
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
void buildTreeMinSum(int *a, int *tree, int start, int end, int treeNode) | |
{ | |
if (start == end) | |
{ | |
tree[treeNode] = a[start]; | |
return; | |
} | |
int mid = (start + end) / 2; | |
buildTreeMinSum(a, tree, start, mid, 2 * treeNode); | |
buildTreeMinSum(a, tree, mid + 1, end, (2 * treeNode) + 1); | |
tree[treeNode] = min(tree[2 * treeNode], tree[(2 * treeNode) + 1]); | |
return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment