Skip to content

Commit

Permalink
Merge branch 'features/segment-tree-implementation'
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramy-Badr-Ahmed committed Sep 30, 2024
2 parents e4cadc8 + 98a41ee commit 6c64c35
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions DataStructures/SegmentTree/SegmentTree.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function getCurrentArray(): array
}

/**
* Builds the segment tree recursively.
* Builds the segment tree recursively. Takes O(n log n) in total.
*
* @param array $arr The input array.
* @param int $start The starting index of the segment.
Expand Down Expand Up @@ -115,7 +115,7 @@ private function buildTree(array $arr, int $start, int $end): SegmentTreeNode
}

/**
* Queries the aggregated value over a specified range.
* Queries the aggregated value over a specified range. Takes O(log n).
*
* @param int $start The starting index of the range.
* @param int $end The ending index of the range.
Expand Down Expand Up @@ -164,7 +164,7 @@ private function queryTree(SegmentTreeNode $node, int $start, int $end)
}

/**
* Updates the value at a specified index in the segment tree.
* Updates the value at a specified index in the segment tree. Takes O(log n).
*
* @param int $index The index to update.
* @param int|float $value The new value to set.
Expand Down

0 comments on commit 6c64c35

Please sign in to comment.