Implementation of a segment tree.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
placeholder |
any
|
A placeholder value dpendent on the aggregate. |
aggregate |
function
|
Generates the values for the intermediate nodes. |
Example
var SegmentTree = require('path-to-algorithms/src/data-structures'+
'/segment-tree').SegmentTree;
var tree = SegmentTree.indexArray([-1, 2, 4, 0], Infinity, function (a, b) {
return Math.min(a, b);
});