差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

両方とも前のリビジョン前のリビジョン
次のリビジョン両方とも次のリビジョン
programming_algorithm:data_structure:binary_indexed_tree [2020/12/13] – [より柔軟な実装] ikatakosprogramming_algorithm:data_structure:binary_indexed_tree [2020/12/13] – [より柔軟な実装] ikatakos
行 90: 行 90:
         self.func = func         self.func = func
         self.idf = identity_factory         self.idf = identity_factory
-        self.depth = n.bit_length() 
  
     def add(self, i, x):     def add(self, i, x):
行 108: 行 107:
         return s         return s
  
-    def lower_bound(self, x, lt): 
-        """ 
-        累積和がx以上になる最小のindexと、その直前までの累積和(未検証) 
- 
-        :param lt: lt(a, b) で a < b ならTrueを返す関数 
-        """ 
-        total = self.idf() 
-        pos = 0 
-        tree = self.tree 
-        func = self.func 
-        for i in range(self.depth, -1, -1): 
-            k = pos + (1 << i) 
-            new_total = func(total, tree[k]) 
-            if k <= self.size and lt(new_total, x): 
-                total = new_total 
-                pos += 1 << i 
-        return pos + 1, total 
 </sxh> </sxh>
  
programming_algorithm/data_structure/binary_indexed_tree.txt · 最終更新: 2023/02/08 by ikatakos
CC Attribution 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0