Skip to content

Commit 2db4c8d

Browse files
Added comment to Fenwick Tree
1 parent 920974a commit 2db4c8d

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

data_structures/fenwick_tree/fenwick_tree.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ def LSB(n):
77

88

99
class FenwickTree:
10+
'''
11+
A Fenwick Tree allows you to sum a range of elements and update an element in an array in O(log(n)). A segment tree
12+
can also achieve this, but it takes twice the memory, making it less memory efficient. On the other hand, a segment tree
13+
can compute more functions in a range of elements, like the minimum or maximum.
14+
'''
15+
1016
def __init__(self, array):
1117
self.len = len(array)+1
1218
self.arr = [0] * self.len

0 commit comments

Comments
 (0)