MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / update

Method update

data_structures/binary_tree/fenwick_tree.py:107–127  ·  view source on GitHub ↗

Set the value of index in O(lg N) Parameters: index (int): index to set value to value (int): value to set in index Returns: None >>> f = FenwickTree([5, 4, 3, 2, 1]) >>> f.update(0, 1) >>> f.update(1, 2)

(self, index: int, value: int)

Source from the content-addressed store, hash-verified

105 index = self.next_(index)
106
107 def update(self, index: int, value: int) -> None:
108 """
109 Set the value of index in O(lg N)
110
111 Parameters:
112 index (int): index to set value to
113 value (int): value to set in index
114
115 Returns:
116 None
117
118 >>> f = FenwickTree([5, 4, 3, 2, 1])
119 >>> f.update(0, 1)
120 >>> f.update(1, 2)
121 >>> f.update(2, 3)
122 >>> f.update(3, 4)
123 >>> f.update(4, 5)
124 >>> f.get_array()
125 [1, 2, 3, 4, 5]
126 """
127 self.add(index, value - self.get(index))
128
129 def prefix(self, right: int) -> int:
130 """

Callers 5

draw_vicsek_fractalFunction · 0.45
kruskFunction · 0.45
boruvkaMethod · 0.45
convex_hull_bfFunction · 0.45
solutionFunction · 0.45

Calls 2

addMethod · 0.95
getMethod · 0.95

Tested by

no test coverage detected